Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ok/No Checks #9

Open
trans opened this issue Jul 16, 2011 · 1 comment
Open

Ok/No Checks #9

trans opened this issue Jul 16, 2011 · 1 comment

Comments

@trans
Copy link
Member

trans commented Jul 16, 2011

Currently we have something like this:

TestCase HelloWorld do

  Setup do
    HelloWorld.new
  end

  Unit :hello => "aspect" do |hello_world|
    ...
  end

end

This creates a "setup" and the return value of the setup procedure is passed to the unit test.

One of the features of KO that would be nice to see in Lemon is ok/no checks. These are calls that rerun a test passing
new arguments to it. In KO it look like this:

Test.case HelloWorld do

  test "aspect" do |arg|
     ...
  end

  ok "arg"
  no "arg"

end

We could move Lemon in that direction by simply adding ok/no methods, like so:

TestCase HelloWorld do

  Unit :hello => "aspect" do |arg|
    ...
  end

  Ok "arg"
  No "arg"

end

But then how does setup's return value come into play? Do we simple combine the arguments?

TestCase HelloWorld do

  Setup do
    HelloWorld.new
  end

  Unit :hello => "aspect" do |hello_world, arg|
    ...
  end

  Ok "arg"
  No "arg"

end

First off, it may be very tricky to implment this combination, as currently it depends on arity == 0 or not as to whether setup's return value is passed, which would no longer work.

On second thought, the use of Ok/No style tests will often preclude the use of setup return value b/c the arguments are likely to define a new instance of the target class. Perhaps then setup should take the arg and pass any needed args on the the test method.

TestCase HelloWorld do

  Setup do |arg1, arg2|
    [ HelloWorld.new(arg1), arg2 ]
  end

  Unit :hello => "aspect" do  |hello_world, arg2|
    ...
  end

  Ok "arg1", "arg2"
  No "arg1", "arg2"

end

If there is no setup method, then the args are passed directly to the unit test.

It seems a bit strange but it is clearly the corrent arrangement.

@trans
Copy link
Member Author

trans commented Jul 16, 2011

On the other hand, we might simply use instance variables like regular folk.

TestCase HelloWorld do

  Setup do |arg1, arg2|
    @hello_world = HelloWorld.new(arg1)
  end

  Unit :hello => "aspect" do  |arg1, arg2|
    @hello_world ...
  end

  Ok "arg1", "arg2"
  No "arg1", "arg2"

end

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant