题目推荐模块
编号 | 测试用例描述 | 输入值 | 预期结果 | 实际结果 | 备注 |
1 | 题目输入的长度超过规定需求 | 失败并提示错误信息 | 失败并提示错误信息 | 异常情况 | |
2 | 输入的问题是英语,用英语回答问题 | Generate five questions about threads | 回答成功 | 回答成功 | 正常流程 |
3 | 一次性输入题目不止一个问题 | 生成5个线程的题目? | 回答成功(两个问题都回答) | 回答成功 | 正常情况 |
4 | 输入的都是特殊符号无法解析 | abcdefghi | 失败并提示错误信息 | 失败并提示错误信息 | 异常情况 |
5 | 输入为空 | 失败并提示错误信息 | 失败并提示错误信息 | 异常情况 | |
7 | 输入了错误的学科词汇 | 生成10个计算机络网的选择题 | 回答成功 | 回答成功 | 证明大模型有一定的容错性(容错性测试) |
8 | 题目不仅要求生成题目还要生成对应答案 解析 | 生成5个线程的题目及其答案 | 回答成功 | 回答成功 | 大模型的应变性很强(应变性测试) |
测试脚本:
import org.junit.*;
import org.openqa.selenium.*;
import org.openqa.selenium.firefox.*;
import org.openqa.selenium.support.ui.*;
import java.io.File;
public class QuestionSubmissionTests {
private WebDriver driver;
@Before
public void setup() {
System.setProperty("webdriver.gecko.driver", "D:\\Drivers\\geckodriver.exe");
File pathBinary = new File("D:\\Firefox\\firefox.exe");
FirefoxBinary firefoxBinary = new FirefoxBinary(pathBinary);
FirefoxOptions options = new FirefoxOptions();
options.setBinary(firefoxBinary);
driver = new FirefoxDriver(options);
driver.manage().window().maximize();
driver.get("http://your-test-url.com");
}
@After
public void tearDown() {
if (driver != null) {
driver.quit();
}
}
private void submitQuestion(String question) {
WebElement questionInput = driver.findElement(By.name("question"));
WebElement submitButton = driver.findElement(By.name("submit"));
questionInput.sendKeys(question);
submitButton.click();
}
private WebElement waitForElement(By locator) {
return new WebDriverWait(driver, 10).until(ExpectedConditions.visibilityOfElementLocated(locator));
}
@Test
public void testLongQuestionInput() {
submitQuestion("This is a very long question that exceeds the maximum allowed length for questions in the system...");
WebElement result = waitForElement(By.id("result"));
Assert.assertTrue(result.getText().contains("题目输入的长度超过规定需求"));
}
@Test
public void testEnglishQuestion() {
submitQuestion("Generate five questions about threads");
WebElement result = waitForElement(By.id("result"));
Assert.assertTrue(result.getText().contains("回答成功"));
}
@Test
public void testMultipleQuestionsInput() {
submitQuestion("生成5个线程的题目?生成10个计算机网络的选择题");
WebElement result = waitForElement(By.id("result"));
Assert.assertTrue(result.getText().contains("回答成功"));
}
@Test
public void testSpecialCharactersInput() {
submitQuestion("abcdefghi");
WebElement result = waitForElement(By.id("result"));
Assert.assertTrue(result.getText().contains("输入无法解析"));
}
@Test
public void testEmptyQuestionInput() {
submitQuestion("");
WebElement result = waitForElement(By.id("result"));
Assert.assertTrue(result.getText().contains("无法提交"));
}
@Test
public void testIncorrectDisciplineTerm() {
submitQuestion("生成10个计算机络网的选择题");
WebElement result = waitForElement(By.id("result"));
Assert.assertTrue(result.getText().contains("回答成功"));
}
@Test
public void testQuestionWithAnswersAndExplanations() {
submitQuestion("生成5个线程的题目及其答案");
WebElement result = waitForElement(By.id("result"));
Assert.assertTrue(result.getText().contains("回答成功"));
}
}
答案测评
编号 | 测试用例描述 | 输入值 | 预期结果 | 实际结果 | 备注 |
1 | 题目输入的长度超过规定需求 | 失败并提示错误信息 | 失败并提示错误信息 | 异常情况 | |
2 | 答案输入的长度超过规定需求 | 失败并提示错误信息 | 失败并提示错误信息 | 异常情况 | |
4 | 输入的都是特殊符号无法解析 | abcdefghi | 失败并提示错误信息 | 失败并提示错误信息 | 异常情况 |
5 | 答案输入为空 | 失败并提示错误信息 | 失败并提示错误信息 | 异常情况 | |
6 | 题目输入为空 | 失败并提示错误信息 | 失败并提示错误信息 | 异常情况 | |
7 | 答案中输入了错误的学科词汇 | ..... | 测评中可以发现 | 测评中可以发现 | 证明大模型有一定的容错性(容错性测试) |
8 | 题目中输入了错误的学科词汇 | 计算机落网的定义 | 测评中可以发现 | 测评中可以发现 | 测评不仅针对答案,也针对题目 |
import org.junit.*;
import org.openqa.selenium.*;
import org.openqa.selenium.firefox.*;
import org.openqa.selenium.support.ui.*;
import java.io.File;
public class QuestionAndAnswerSubmissionTests {
private WebDriver driver;
@Before
public void setup() {
System.setProperty("webdriver.gecko.driver", "D:\\Drivers\\geckodriver.exe");
File pathBinary = new File("D:\\Firefox\\firefox.exe");
FirefoxBinary firefoxBinary = new FirefoxBinary(pathBinary);
FirefoxOptions options = new FirefoxOptions();
options.setBinary(firefoxBinary);
driver = new FirefoxDriver(options);
driver.manage().window().maximize();
driver.get("http://your-test-url.com");
}
@After
public void tearDown() {
if (driver != null) {
driver.quit();
}
}
private void submitQuestionAndAnswer(String question, String answer) {
WebElement questionInput = driver.findElement(By.name("question"));
WebElement answerInput = driver.findElement(By.name("answer"));
WebElement submitButton = driver.findElement(By.name("submit"));
questionInput.sendKeys(question);
answerInput.sendKeys(answer);
submitButton.click();
}
private WebElement waitForElement(By locator) {
return new WebDriverWait(driver, 10).until(ExpectedConditions.visibilityOfElementLocated(locator));
}
@Test
public void testLongQuestionInput() {
String longQuestion = "This is a very long question that exceeds the maximum allowed length for questions in the system...";
String validAnswer = "Valid answer.";
submitQuestionAndAnswer(longQuestion, validAnswer);
WebElement result = waitForElement(By.id("result"));
Assert.assertTrue(result.getText().contains("题目输入的长度超过规定需求"));
}
@Test
public void testLongAnswerInput() {
String validQuestion = "Valid question.";
String longAnswer = "This is a very long answer that exceeds the maximum allowed length for answers in the system...";
submitQuestionAndAnswer(validQuestion, longAnswer);
WebElement result = waitForElement(By.id("result"));
Assert.assertTrue(result.getText().contains("答案输入的长度超过规定需求"));
}
@Test
public void testSpecialCharactersInput() {
String specialCharsQuestion = "abcdefghi";
String specialCharsAnswer = "abcdefghijk";
submitQuestionAndAnswer(specialCharsQuestion, specialCharsAnswer);
WebElement result = waitForElement(By.id("result"));
Assert.assertTrue(result.getText().contains("无法解析"));
}
@Test
public void testEmptyAnswerInput() {
String validQuestion = "Valid question.";
String emptyAnswer = "";
submitQuestionAndAnswer(validQuestion, emptyAnswer);
WebElement result = waitForElement(By.id("result"));
Assert.assertTrue(result.getText().contains("答案不能为空"));
}
@Test
public void testEmptyQuestionInput() {
String emptyQuestion = "";
String validAnswer = "Valid answer.";
submitQuestionAndAnswer(emptyQuestion, validAnswer);
WebElement result = waitForElement(By.id("result"));
Assert.assertTrue(result.getText().contains("题目不能为空"));
}
@Test
public void testIncorrectDisciplineTermInAnswer() {
String validQuestion = "Valid question.";
String incorrectDisciplineAnswer = "计算机络网的定义";
submitQuestionAndAnswer(validQuestion, incorrectDisciplineAnswer);
WebElement result = waitForElement(By.id("result"));
Assert.assertTrue(result.getText().contains("正确回答"));
}
@Test
public void testIncorrectDisciplineTermInQuestion() {
String incorrectDisciplineQuestion = "计算机落网的定义";
String validAnswer = "Valid answer.";
submitQuestionAndAnswer(incorrectDisciplineQuestion, validAnswer);
WebElement result = waitForElement(By.id("result"));
Assert.assertTrue(result.getText().contains("测评中可以发现"));
}
@Test
public void testQuestionAndAnswerWithIncorrectDisciplineTerms() {
String incorrectDisciplineQuestion = "计算机落网的定义";
String incorrectDisciplineAnswer = "计算机网络是指由多个计算机及其他硬件设备通过通信介质相互连接而成的系统,以实现资源共享和信息交换的目的。计算机网络可以分为局域网(Local Area Network, LAN)、广域网(Wide Area Network, WAN)、城域网(Metropolitan Area Network, MAN)和个人区域网(Personal Area Network, PAN)等类型。";
submitQuestionAndAnswer(incorrectDisciplineQuestion, incorrectDisciplineAnswer);
WebElement result = waitForElement(By.id("result"));
Assert.assertTrue(result.getText().contains("测评中可以发现"));
}
}