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)
commite47f39f90453a104323b7e7cca8f9627d77a77fe
tree7ee71a17788b6d110ef1078f93e4f134587f156b
parentc86718ed33c02a612774f026b4b2ab18338ef96a
parent1431fadb8e2037e91fb2ff44dc528e79b6857d35
Merge: niunit: fix after/before test calls

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>