For the "number of tests"
public class FailingBeforeTestIncreaseNumberOfTests
{
@BeforeClass
protected void init() {
}
@BeforeTest
protected void clean() {
throw new RuntimeException("failure");
}
@Test(groups={"testng"})
public void oneTest() {
}
}
I run this test class with this code, then replaced @BeforeTest by
@BeforeMethod, then removed throw from @BeforeMethod
running under eclipse I've
with @BeforeTest
Tests : 1/1 Methods=3/1, Passed=0, Failed=1, Skipped=2
with @BeforeMethod
Tests : 1/1 Methods=2/1, Passed=0, Failed=1, Skipped=1
with @BeforeMethod with no throw
Tests : 1/1 Methods=1/1, Passed=1, Failed=0, Skipped=0
running under surefire, I've
with @BeforeTest
Tests run: 3, Failures: 1, Errors: 0, Skipped: 2, Time elapsed: 0.436
sec <<< FAILURE!
with @BeforeMethod with throw
Tests run: 2, Failures: 1, Errors: 0, Skipped: 1, Time elapsed: 0.436
sec <<< FAILURE!
with @BeforeMethod without throw
Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.427
sec
so i looks like surefire displays the eclipse "Methods" as "Test run"
i both display, a failing @BeforeTest make the @BeforeTest look like a
Skipped test
this is not important for me, as I my goal is to have some good tests
and, since one time, no more failure on them :)
On 24 avr, 17:06, Cédric Beust ♔ <
cbe...@google.com> wrote:
> That's certainly surprising, can you post an example where changing a
> @BeforeTest into a @BeforeMethod will change the number of tests run?
>
> Cédric