Merge: nitunit: use annotations
authorJean Privat <jean@pryen.org>
Mon, 25 Sep 2017 20:23:07 +0000 (16:23 -0400)
committerJean Privat <jean@pryen.org>
Mon, 25 Sep 2017 20:23:07 +0000 (16:23 -0400)
commit5b1314e90d5bbefa3e1008e57da7a3b2780b4022
treeffe0a17fca8a85d112e33d72a32ce9731b568707
parentbf4e283c43a0f2d189c3bf4d206db1049c9107cf
parente6d0f9e978c56bf76ba2926c41e18da0e630b38d
Merge: nitunit: use annotations

This PR replace the name heuristics used by nitunit by nice and tidy annotations.

Before:

~~~nit
module test_my_test is test_suite

import test_suite

class TestMyTest
    super TestSuite

    redef fun before do # something

    fun test_my_test do
        assert true
    end
end
~~~

After:

~~~nit
module my_test is test

class MyTest
    test

    fun setup is before do # something

    fun my_test is test do
        assert true
    end
end
~~~

Motivations:
* cleaner API / naming policy
* [BDD](https://en.wikipedia.org/wiki/Behavior-driven_development) friendly
* more flexibility as one can define a `after` method in the lib that will only be executed on children module tagged with `test`
* more extensible as one can improve nitunit to support `test(timeout = 150)` or `test(res= "res/test_file.res")`

Used annotations:
* `test` on modules, classes and properties to indicate that nitunit must run this module/class/method
* `before`, `after` on properties from all classes but `Sys` for the before/after each case hooks
* `before_all`, `after_all` on properties from `Sys` for the before/after all cases hooks

This also removes the need of the `lib/test_suite` module.

I also migrated the existing test suites to the new annotations system. Let's see what Jenkins has to say about it.

Should fix #2165

Pull-Request: #2474
Reviewed-by: Jean Privat <jean@pryen.org>
src/loader.nit
src/model/test_model_json.nit
src/web/web_base.nit