ignite-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Ivan Fedotov <ivanan...@gmail.com>
Subject beforeTest, afterTest JUnit scenario implementation
Date Wed, 20 Mar 2019 14:37:38 GMT
Hi Igniters!

I have a questions according to beforeTest(s)/afterTest(s) methods. I tried
to make them correspond to JUnit 4+ semantics in the context of iep30 [1].
And I see there two solutions:

1. Place test scenario under the Rule annotation as it has already done in
GridAbstractTest [2]. It is a built-in opportunity to extend JUnit
framework. Such case already implemented and demands minimal changes. To
add before and after test logic in the other classes, it is necessary to
override corresponding methods.

2. Write before and after test logic with annotations in GridAbstractTest
and all other classes. Such solution is less flexible in comparison with
rules. Moreover, under annotation, a code will be less readable than under
rule. But such approach decreases coupling between classes.

The main argumentation in favor of the first approach is that there are
minimal changes in code. According to this during migration on other JUnit
versions, there is no need to fix all test files to change imports and
annotations (for instance, in JUnit5 Before/BeforeClass, After/AfterClass
annotations were changed). Changes will affect only GridAbstractTest
class.  At the same time, the possibility to use annotations remains.

Now I started to implement the first approach [3] - specify test scenario
under the Rule annotation and override methods if it is necessary.
Such functionality is similar to the third version, but with 4+ semantics
and with minimal changes during migration.

What do you think, which approach will be better for the community?

[1]
https://cwiki.apache.org/confluence/display/IGNITE/IEP-30%3A+Migration+to+JUnit+5
[2]
https://github.com/apache/ignite/blob/master/modules/core/src/test/java/org/apache/ignite/testframework/junits/GridAbstractTest.java#L181
[3]https://github.com/apache/ignite/pull/6227/files

-- 
Ivan Fedotov.

ivanan639@gmail.com

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message