(一)测试用例-思维导图格式展示
(二)项目简介及测试内容(功能测试)
在线网页版五子棋对战:
实现用户注册 ,用户登录 ,用户天梯分数记录 ,用户比赛场次记录
按照用户的天梯分数实现匹配机制
实现两个玩家在页面端进行五子棋在线对战的功能
测试内容:本次测试只对项目功能进行测试,测试方法为黑盒测试。
测试环境:Chrome 版本 112.0.5615.50(正式版本)(64 位)电脑:华硕 ASUS TUF Gaming A15(64位)
目前只对项目的主要功能进行了测试,并未对其它功能以及项目本身进行全面测试
(三)自动化测试
这里我使用的是junit+selenium进行测试的,后续的学习中我会去尝试学习python并且利用python进行自动化测试~~目前只会junit,所以这里都是对功能的简单测试,主要是检测功能是否正常
(1)登录功能测试
@Test
public void test() throws InterruptedException {
ChromeDriver driver = new ChromeDriver();
driver.get("http://43.142.89.63:8089/login.html");
Thread.sleep(2000);
driver.findElement(By.cssSelector("#username")).sendKeys("aaa");
driver.findElement(By.cssSelector("#password")).sendKeys("123");
Thread.sleep(2000);
driver.findElement(By.cssSelector("#submit")).click();
Thread.sleep(2000);
Alert alert = driver.switchTo().alert();
String str = alert.getText();
Assertions.assertEquals("登录成功!", str);
Thread.sleep(2000);
driver.quit();
}
登录测试
(2)注册功能测试
@Test
public void test2() throws InterruptedException {
ChromeDriver driver = new ChromeDriver();
driver.get("http://43.142.89.63:8089/login.html");
Thread.sleep(2000);
driver.findElement(By.cssSelector("#submit2")).click();
Thread.sleep(2000);
driver.findElement(By.cssSelector("#username")).sendKeys("lisi6");
Thread.sleep(2000);
driver.findElement(By.cssSelector("#password")).sendKeys("123");
Thread.sleep(2000);
driver.findElement(By.cssSelector("#submit")).click();
Thread.sleep(2000);
Alert alert = driver.switchTo().alert();
String str = alert.getText();
Assertions.assertEquals("注册成功!", str);
Thread.sleep(2000);
driver.quit();
注册测试
(2)匹配功能测试
匹配功能是打开两个网页一个是chrome另一个是edge,登录两个用户,然后同时匹配,检测匹配功能是否正常,如果正常两个用户的页面会自动初始化棋盘
@Test
public void Test() throws InterruptedException {
ChromeDriver driver = new ChromeDriver();
driver.get("http://43.142.89.63:8089/login.html");
Thread.sleep(2000);
driver.findElement(By.cssSelector("#username")).sendKeys("aaa");
driver.findElement(By.cssSelector("#password")).sendKeys("123");
Thread.sleep(2000);
driver.findElement(By.cssSelector("#submit")).click();
Thread.sleep(2000);
Alert alert = driver.switchTo().alert();
alert.accept();
driver.findElement(By.cssSelector("#match-button")).click();
Thread.sleep(10000);
String str = alert.getText();
Assertions.assertEquals("登录成功!", str);
Thread.sleep(2000);
driver.quit();
}
@Test
public void Test2() throws InterruptedException {
System.setProperty("webdriver.ie.driver", "E:\\tool\\python\\Scripts\\MicrosoftWebDriver.exe");
EdgeDriver driver=new EdgeDriver();
driver.get("http://43.142.89.63:8089/login.html");
driver.findElement(By.cssSelector("#username")).sendKeys("lisi1");
driver.findElement(By.cssSelector("#password")).sendKeys("123");
Thread.sleep(2000);
driver.findElement(By.cssSelector("#submit")).click();
Thread.sleep(2000);
Alert alert = driver.switchTo().alert();
alert.accept();
driver.findElement(By.cssSelector("#match-button")).click();
Thread.sleep(10000);
String str = alert.getText();
Assertions.assertEquals("登录成功!", str);
Thread.sleep(2000);
driver.quit();
}
匹配测试