Ok, Thank you for this reply, I realize that I haven't been clear enough with my explanations (Indeed, I don't want to "have one initialization method called exactly once before any test execution and one after the last test" as you thought in your reply).
I try again : If we consider that semantic of "@before" and "@after" aims to set an initial state and clear the final state for each unit call, I would like to be able to "see" this with contiPerf :
- Code: Select all
before()
test1()
after()
before()
test1()
after()
before()
test2()
after()
before()
test2()
after()
At the moment, as contiPerf is designed to link a second test1() call directly to the first test1() call, the concern is that the second call will start based on the final state of the first test1() call, what is, in my opinion, not necessarly expected.
Let's check this case :
- Code: Select all
@Before
public void init(){
//clear the DB
}
@Test
public void test1(){
//insert 1 row
// assertTrue that there is 1 row and only 1 row in the table
}
If I use a contiPerf annnotation in order to make 2 invocations for test1(), the second call will fail, right ?
Writing this post, I wonder if I am not totally wrong with my use of contiPerf : maybe It's not a good idea to mix my "business" JUnit tests with contiPerf ? Shall I dedicate classes only for performance tests with contiPerf ? Just let me know your thinkings about this.
Even if it were not a good idea to mix business and performance tests, for the moment I am unable to implement something like this :
- Code: Select all
public class LoginTest {
private String login;
private String password;
@Before
public void init(){
//set login and password attributes from a list (randomly)
}
@Test
public void testPerfLogin{
//call a login method to test, passing the parameters "login" and "password"
}
}
because only one couple of login/password will be used for the entire performance test.
If my concern is "valid" : I suppose we could imagine to introduce some new contiPerfs annotations, such as "@BeforeEachInvocation" and "@AfterEachInvocation" ?
Thank you !