Merge: niunit: fix after/before test calls
authorJean Privat <jean@pryen.org>
Wed, 16 Dec 2015 17:12:22 +0000 (12:12 -0500)
committerJean Privat <jean@pryen.org>
Wed, 16 Dec 2015 17:12:22 +0000 (12:12 -0500)
The specification of `nitunit` states that before and after methods can be called to initialize or clean test related things:

~~~nit
module my_test_suite

class MyTestSuite
    super TestSuite

    redef fun before_test do
          # complex things to set up the test
    end

    redef fun after_test do
          # complex things to tear down the test
    end

    fun test_foo do end
    fun test_bar do end
end
~~~

In the above example, `nitunit` will call the methods precisely in this order:

~~~nit
test_before
test_foo
test_after
test_before
test_bar
test_after
~~~

Before this PR, the before and after methods were only call if a redefinition of the before/after method exists locally in the test suite. Inheritance was not considered:

~~~nit
module my_test_suite

class TestBase
    super TestSuite

    redef fun before_test do # ...
    redef fun after_test do # ...
end

class MyTestSuite
    super TestBase

    fun test_foo do end
    fun test_bar do end
end
~~~

So the output was only:

~~~nit
test_foo
test_bar
~~~

This PR fixes that behavior.

Pull-Request: #1897
Reviewed-by: Jean Privat <jean@pryen.org>


Trivial merge