I use Spring Test with TestNG to test our DAOs, and I wanted to run a specific text device script before certain methods, allowing the changes to be discarded after each method so that the tests were free to do anything with the device data.
Initially, I thought that βgroupsβ were suitable for him, but I already realized that they were not intended for this (see this question: TestNG BeforeMethod with groups ).
Is there a way to configure the method @BeforeMethodto run only up to a specific @Tests? The only thing I see is workarounds:
- Define a typical installation method and call at the beginning of each method
@Test; - Move the method
@BeforeMethodto a new class (top level or inner class) along with all the methods that depend on it.
None of them are perfect, I would like my tests to be naturally grouped and clean, and not separated due to lack of alternatives.
source
share