You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I was thinking to use BDD style testing with testng by using inner classes. This nearly works except the order of things messes up the intended behavior so I was wondering if this is something worth fixing in testng.
In the test below the first given never executes because there is no test method in the outerclass. If you add one it does execute but at the wrong time only after the innner tests run. So beforeclass is actually running at the wrong time (bug?).
I realize that this is stretching the original design goals a bit but it might actually be kind of neat if this could be made to work. It would basically allow for BDD style tests.
There seem to be two issues that prevent this from working.
Classes labeled with @test never execute their @BeforeClass method unless they have test methods.
Inner classes are not really part of the test and so inner and outer methods are executed in the wrong order. The outer given actually executes after the tests of the inner classes run. With @before I get similar results.
@Test
public class BddTest {
@BeforeClass
public void given() {
System.out.println("given some shared stuff");
}
@Test
public static class DescribeSomeFunctionality {
@BeforeClass
public void given() {
System.out.println("given some more specific stuff ");
}
public void itShouldDoFoo() {
System.out.println("foo");
}
public void itShouldDoBar() {
System.out.println("bar");
}
}
@Test
public static class DescribeSomeMoreFunctionality {
@BeforeClass
public void given() {
System.out.println("given some other stuff ");
}
public void shouldRunThisToo() {
System.out.println("bar");
}
}
}
The text was updated successfully, but these errors were encountered:
I was thinking to use BDD style testing with testng by using inner classes. This nearly works except the order of things messes up the intended behavior so I was wondering if this is something worth fixing in testng.
In the test below the first given never executes because there is no test method in the outerclass. If you add one it does execute but at the wrong time only after the innner tests run. So beforeclass is actually running at the wrong time (bug?).
I realize that this is stretching the original design goals a bit but it might actually be kind of neat if this could be made to work. It would basically allow for BDD style tests.
There seem to be two issues that prevent this from working.
Classes labeled with @test never execute their @BeforeClass method unless they have test methods.
Inner classes are not really part of the test and so inner and outer methods are executed in the wrong order. The outer given actually executes after the tests of the inner classes run. With @before I get similar results.
A related issues might be #475
The text was updated successfully, but these errors were encountered: