I started to learn about automation testing and I am trying to testing with Intellij using apache-maven 1.8 & selenium-server. I have also installed JDK11. and I try to exercise by testing web, so I created two classes which are homepage & apptest.
Here is my code (homepage.java)
package org.example.page;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import static junit.framework.Assert.assertEquals;
public class homepage {
private WebDriver webDriver;
public homepage(WebDriver driver) {
this.webDriver = driver;
}
public void assertOpenHomePage() throws InterruptedException {
Thread.sleep(3000);
String welcomeHomePage = String.valueOf(webDriver.findElement(By.xpath
("//strong[contains(text(),'Selenium Easy!')]")).getText());
assertEquals("Selenium Easy!", welcomeHomePage);
}
and this is the code for the apptest (apptest.java)
package org.example;
import junit.framework.TestCase;
import org.example.page.homepage;
import org.junit.Before;
import org.junit.Test;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.chrome.ChromeOptions;
/**
* Unit test for simple App.
*/
public class AppTest
extends TestCase
{
WebDriver webDriver;
@Before
public void initiate(){
ChromeOptions options = new ChromeOptions();
options.addArguments("Start-Maximized");
webDriver = new ChromeDriver(options);
}
@Test
public void openHomePage() throws InterruptedException {
homepage homepage = new homepage(webDriver);
webDriver.get("https://www.seleniumeasy.com/");
homepage.assertOpenHomePage();
}
}
but when i run the apptest.java, there such an error report:
junit.framework.AssertionFailedError: No tests found in org.example.AppTest
at junit.framework.Assert.fail(Assert.java:57)
at junit.framework.TestCase.fail(TestCase.java:223)
at junit.framework.TestSuite$1.runTest(TestSuite.java:96)
Please help me to resolve this problem, thank you so much!