Reputation: 509
My requirement goes like this.
The problem is, for each @Test methods in the same class I need to perform both step 1 and 2 which is a time taking and unnecessary. The property retrieved from 'step 1' will be the same throughout the execution of the tests in the class.
Is there anyway I can execute 'step 1' just once at the start of the test and use the property value returned for all the @Test methods in the class following it?
P.S- I checked on the dependsOnMethods annotation and not sure whether it is a solution I am looking for.
Upvotes: 0
Views: 1184
Reputation: 641
If you're using JUnit, it sounds like @BeforeClass
is what you are looking for. Method with this annotation runs only once per class and you can store any value returned in a global variable. Or, you might consider @Before
annotation (runs before each test) if that suits you better.
Other testing frameworks use similar idea.
Upvotes: 1