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. [hidden email] |
Hi Ivan,
During migration from junit 3 to 4 multiple options was discussed [1]. And the main decision about before/after test method was making as less as possible changes in already existing tests with adding an ability to write new tests using common junit 4 style (i.e. using annotations in new tests). And it seems that mentioned above correlates with your approach. [1] http://apache-ignite-developers.2346864.n4.nabble.com/Is-it-time-to-move-forward-to-JUnit4-5-td29608.html ср, 20 мар. 2019 г. в 17:38, Ivan Fedotov <[hidden email]>: > > 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. > > [hidden email] -- Best regards, Ivan Pavlukhin |
Hi Ivan,
Thank you for your response. In this way, I will finish IGNITE-11411-13 tickets with Rule annotation and minimal changes. чт, 21 мар. 2019 г. в 21:19, Павлухин Иван <[hidden email]>: > Hi Ivan, > > During migration from junit 3 to 4 multiple options was discussed [1]. > And the main decision about before/after test method was making as > less as possible changes in already existing tests with adding an > ability to write new tests using common junit 4 style (i.e. using > annotations in new tests). > > And it seems that mentioned above correlates with your approach. > > [1] > http://apache-ignite-developers.2346864.n4.nabble.com/Is-it-time-to-move-forward-to-JUnit4-5-td29608.html > > ср, 20 мар. 2019 г. в 17:38, Ivan Fedotov <[hidden email]>: > > > > 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. > > > > [hidden email] > > > > -- > Best regards, > Ivan Pavlukhin > -- Ivan Fedotov. [hidden email] |
Free forum by Nabble | Edit this page |