Skip to content

Commit

Permalink
Update tests
Browse files Browse the repository at this point in the history
  • Loading branch information
ngoanh2n committed May 27, 2023
1 parent ff2de0b commit 6d285bf
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
public class BeforeAllTest extends WDCJUnit5Test {
@BeforeAll
static void beforeAll() {
Assertions.assertThrows(CheckerException.class, WebDriverChecker::getDriver);
Assertions.assertThrows(CheckerException.NullDriverProvided.class, WebDriverChecker::getDriver);
createWebDriver();
Assertions.assertNotNull(WebDriverChecker.getDriver());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
public class BeforeEachTest extends WDCJUnit5Test {
@BeforeAll
static void beforeAll() {
Assertions.assertThrows(CheckerException.class, WebDriverChecker::getDriver);
Assertions.assertThrows(CheckerException.NullDriverProvided.class, WebDriverChecker::getDriver);
}

@BeforeEach
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,20 +13,21 @@
public abstract class WDCJUnit5Test {
protected static WebDriver driver;

@AfterEach
protected void afterEach() {
Assertions.assertNotNull(WebDriverChecker.getDriver());
}

@AfterAll
protected static void afterAll() {
Assertions.assertNotNull(WebDriverChecker.getDriver());
driver.quit();
Assertions.assertThrows(CheckerException.class, WebDriverChecker::getDriver);
Assertions.assertThrows(CheckerException.ClosedDriverProvided.class, WebDriverChecker::getDriver);
driver = null;
}

protected static void createWebDriver() {
WebDriverManager.chromedriver().setup();
driver = new ChromeDriver();
}

@AfterEach
protected void afterEach() {
Assertions.assertNotNull(WebDriverChecker.getDriver());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
public class BeforeClassTest extends WDCTestNGTest {
@BeforeClass
protected void beforeClass() {
Assert.assertThrows(CheckerException.class, WebDriverChecker::getDriver);
Assert.assertThrows(CheckerException.NullDriverProvided.class, WebDriverChecker::getDriver);
createWebDriver();
Assert.assertNotNull(WebDriverChecker.getDriver());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
public class BeforeMethodTest extends WDCTestNGTest {
@BeforeClass
protected void beforeClass() {
Assert.assertThrows(CheckerException.class, WebDriverChecker::getDriver);
Assert.assertThrows(CheckerException.NullDriverProvided.class, WebDriverChecker::getDriver);
}

@BeforeMethod
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@ protected void afterMethod() {
protected void afterClass() {
Assert.assertNotNull(WebDriverChecker.getDriver());
driver.quit();
Assert.assertThrows(CheckerException.class, WebDriverChecker::getDriver);
Assert.assertThrows(CheckerException.ClosedDriverProvided.class, WebDriverChecker::getDriver);
driver = null;
}

protected static void createWebDriver() {
Expand Down

0 comments on commit 6d285bf

Please sign in to comment.