Open thienphuong opened 12 months ago
Mỗi một describe
blocks tương ứng như một class
. Bố cục giống việc sử dụng Nested Test Classes của Junit5.
If we have setup or tear-down methods that repeat for some of the tests, but not for all of them, a @Nested test class can be very useful.
Furthermore, using nested classes for setting up groups of tests lead to more expressive test scenarios and a clear relationship between our tests.
public class TodoListTest {
Actor actor =Actor.named("jacob") ;
@Nested
class WhenTheUserIs {
@Nested
class AGuest {
@Nested
class TheirList {
@Test
void IsEmpty() {
actor.attemptsTo(
Navigate.to('https://todo-app.serenity-js.org/'),
Ensure.that(displayedItems().count(), equals(0)))
}
}
}
}
@Nested
class SecondNestedClass {
@Test
void test() {
System.out.println("SecondNestedClass.test()");
}
}
}