系统介绍
本项目是咖啡店等企业定制的一款管理系统,包括系统管理后台和移动端应用两部分。咖啡店管理系统是一个基于 Java 语言的系统,其核心目标是为咖啡店提供全面的管理支持。通过这个系统,咖啡店能够实现从个人中心到管理员管理,再到用户管理等一系列的全方位管理功能。
界面截图
主页面
注册页面
咖啡详情页
咖啡评论
测试用例
功能测试
界面测试
接口测试
其它测试
自动化测试脚本
功能测试
package pokemmo;
import org.openqa.selenium.*;
import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.interactions.Actions;
import org.openqa.selenium.support.ui.ExpectedConditions;
import org.openqa.selenium.support.ui.WebDriverWait;
public class Test7 {
public static ChromeDriver chromeDriver;
public static void main(String[] args) throws InterruptedException {
openChrome();
//浏览器全屏
chromeDriver.manage().window().maximize();
//打开该网页
chromeDriver.get("C:\\Users\\20961\\Desktop\\20200510128_曹晓猛_pokemmo游戏网页\\dazuoye.html");
//打开视频
WebElement videoPlayer = chromeDriver.findElement(By.className("shiping"));
videoPlayer.click();
Thread.sleep(30000);
//检查各种链接按钮是否跳转
chromeDriver.findElement(By.linkText("资料")).click();
Thread.sleep(3000);
//navigate对象
WebDriver.Navigation navigation= chromeDriver.navigate();
//回退
navigation.back();
Thread.sleep(3000);
chromeDriver.findElement(By.linkText("账号")).click();
Thread.sleep(3000);
navigation.back();
Thread.sleep(3000);
chromeDriver.findElement(By.linkText("论坛")).click();
Thread.sleep(3000);
navigation.back();
Thread.sleep(3000);
chromeDriver.findElement(By.linkText("查看更多图片!")).click();
Thread.sleep(3000);
navigation.back();
Thread.sleep(3000);
chromeDriver.findElement(By.linkText("立即注册!")).click();
//注册模块测试
Thread.sleep(3000);
//用户名
chromeDriver.findElement(By.id("yonhu")).sendKeys("123456");
//邮箱
chromeDriver.findElement(By.id("txt")).sendKeys("12345678@qq.com");
chromeDriver.findElement(By.id("btn")).click();
Thread.sleep(2000);
//邮箱格式校验
Alert alert=chromeDriver.switchTo().alert();
alert.accept();
Thread.sleep(2000);
//密码
chromeDriver.findElement(By.id("mima")).sendKeys("12345");
//确认密码
chromeDriver.findElement(By.id("queren")).sendKeys("12345");
//验证码
chromeDriver.findElement(By.id("yanzhen")).sendKeys("YVTNAUN");
//订阅
chromeDriver.findElement(By.className("checkbox")).click();
Thread.sleep(3000);
//注册
chromeDriver.findElement(By.id("zhuce")).click();
Thread.sleep(2000);
navigation.back();
Thread.sleep(2000);
navigation.back();
}
public static void openChrome(){
System.setProperty("webdriver.chrome.driver","C:\\IDEA\\Maven-project\\java01\\src\\test\\resource\\chromedriver.exe");
chromeDriver=new ChromeDriver();
}
}
接口测试
import io.restassured.RestAssured;
import io.restassured.http.ContentType;
import io.restassured.response.Response;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
import static io.restassured.RestAssured.given;
import static org.testng.Assert.assertEquals;
//注册接口测试
public class RegistrationAPITest {
private static final String BASE_URL = "http://localhost:7000/login";
private static final String REGISTER_ENDPOINT = "/register";
public void setup() {
RestAssured.baseURI = BASE_URL;
}
// 测试成功注册的情况
public void testSuccessfulRegistration() {
Response response = given()
.contentType(ContentType.URLENC)
.formParam("username", "testuser")
.formParam("password", "password123")
.formParam("confirmPassword", "password123")
.post(REGISTER_ENDPOINT);
assertEquals(response.getStatusCode(), 200);
assertEquals(response.getBody().asString(), "Registration successful");
}
// 测试密码不匹配的情况
public void testPasswordMismatch() {
Response response = given()
.contentType(ContentType.URLENC)
.formParam("username", "testuser")
.formParam("email", "test@example.com")
.formParam("password", "password123")
.formParam("confirmPassword", "password456")
.post(REGISTER_ENDPOINT);
assertEquals(response.getStatusCode(), 400);
assertEquals(response.getBody().asString(), "Passwords do not match");
}
// 测试用户名重复的情况
public void testDuplicateUsername() {
Response response = given()
.contentType(ContentType.URLENC)
.formParam("username", "testuser")
.formParam("email", "newuser@example.com")
.formParam("password", "newpassword123")
.formParam("confirmPassword", "newpassword123")
.post(REGISTER_ENDPOINT);
assertEquals(response.getStatusCode(), 400);
assertEquals(response.getBody().asString(), "Username already exists");
}
}```