junit4 icon indicating copy to clipboard operation
junit4 copied to clipboard

Create a Rule-like structure that can replicate the behavior of Parameterized without using a custom runner

Open dsaff opened this issue 13 years ago • 2 comments

Highly speculative at this point.

dsaff avatar Oct 16 '12 13:10 dsaff

A good start: http://blog.schauderhaft.de/2012/12/16/writing-parameterized-tests-with-junit-rules/

pholser avatar Jan 09 '13 19:01 pholser

This pattern works well, but changes a fundamental aspect of JUnit tests. Typically, each test gets a fresh instantiation of the test object, but this iterates the parameterized test over the same test object. If your test object uses any state (class member variables), it could affect the outcome of the tests. Would this be categorized as bad design for a test class (for having state), or should the rule be redesigned to construct a new test object for each test invocation?

jigawot avatar Aug 06 '15 17:08 jigawot