junit-runner

How to parameterize junit Test Suite

廉价感情. 提交于 2019-12-01 08:59:19
Is it possible to parameterize a TestSuite in junit 4 ? For declaring a class as a test suite I need the annotation @RunWith(Suite.class) , but the same annotation is also needed to declare the test as parameterized: @RunWith(Parameterized.class) so I cannot add both to the same class. I found a similar question in this site that did not help much. So far, all the examples I have found explain how to parameterize simple unit tests, not a complete test tuite. mikemil I believe the basic answer is No, because as you said, the @RunsWith only take one parameter. I found a blog posting that got a

Writing a single unit test for multiple implementations of an interface

只谈情不闲聊 提交于 2019-11-29 20:34:32
I have an interface List whose implementations include Singly Linked List, Doubly, Circular etc. The unit tests I wrote for Singly should do good for most of Doubly as well as Circular and any other new implementation of the interface. So instead of repeating the unit tests for every implementation, does JUnit offer something inbuilt which would let me have one JUnit test and run it against different implementations? Using JUnit parameterized tests I can supply different implementations like Singly, doubly, circular etc but for each implementation the same object is used to execute all the

how to combine @RunWith with @RunWith(Parameterized.class)

↘锁芯ラ 提交于 2019-11-29 04:08:02
I implemented a runner class A.class inherited from BlockJUnit4ClassRunner so that I can annotate tests with @RunWith(A.class). At the same time, sb. else annotate the tests with RunWith(Parameterized.class). It is obvious we cannot use two @RunWith at the same time. How to solve this problem? or how to merge these two @RunWith? Alex I believe this does what you want: package so.junit.runner; import org.junit.Test; import org.junit.runner.RunWith; import org.junit.runners.Parameterized; import org.junit.runners.model.InitializationError; import org.junit.runners.parameterized

Writing a single unit test for multiple implementations of an interface

与世无争的帅哥 提交于 2019-11-28 16:37:45
问题 I have an interface List whose implementations include Singly Linked List, Doubly, Circular etc. The unit tests I wrote for Singly should do good for most of Doubly as well as Circular and any other new implementation of the interface. So instead of repeating the unit tests for every implementation, does JUnit offer something inbuilt which would let me have one JUnit test and run it against different implementations? Using JUnit parameterized tests I can supply different implementations like