600字范文,内容丰富有趣,生活中的好帮手!
600字范文 > 软件测试实验——对新冠肺炎病毒自助检测等(1)

软件测试实验——对新冠肺炎病毒自助检测等(1)

时间:2019-04-14 19:45:56

相关推荐

软件测试实验——对新冠肺炎病毒自助检测等(1)

对新冠肺炎病毒自助检测判断逻辑,采用决策表方法设计测试用例,并编写程序测试之。对于实现的程序,生成控制流图,并确定其圈复杂度。

public class work4 {public static int classify(int[][] a) {String[] b= {"建议立刻发热门诊就诊,并且佩戴好口罩做好防护。佩戴医用外科口罩或N95口罩,避免乘坐公共交通工具。","结合你提供的病情症状及接触史特点,建议继续在家监测体温,可适当服用治疗感冒的中成药,注意手卫生,多饮水,休息为主。若体温持续不退或体温大于38℃或不适症状加重,及时就诊。","建议你们全家及密切接触者居家隔离至少2周,在家期间建议戴口罩交流,条件允许时,尽量单独居住或居住在通风良好的单人房间。多休息,多饮水,注意手卫生和常用物品卫生消毒。若出现发热及呼吸道症状,需马上前往医院就诊。","建议您戴口罩、勤洗手,避免人群聚集,减少不必要外出。"};//System.out.println("1.锟斤拷始症状锟缴硷拷");System.out.println("是否有以下症状?");System.out.println("1发热、2咽喉痛、3咳嗽、4鼻塞、5流鼻涕、6胸闷、7气急、8呼吸困难、9全身酸痛、10乏力、11腹泻、0都没有");if(a[0][0]==0) {if(a[7][0]==0) {System.out.println(b[3]);return 3;}else {System.out.println(b[2]);return 2;}}for(int i=0;i<11;i++) {if(a[0][i]==-1) {break;}switch(a[0][i]) {case 1:System.out.println("目前体温是多少?");if(a[1][0]==0) {System.out.println("<37.3℃");}else {System.out.println("≥37.3℃");}System.out.println("最高体温是多少?");float tem=(float)a[1][1]/10;System.out.println(tem+"℃");System.out.println("发热时有没有以下情况?");if(a[1][2]==0) {System.out.println("发热体温持续不退");}else if(a[1][2]==1) {System.out.println("体温一直大于38℃");}else if(a[1][2]==2) {System.out.println("都没有");}System.out.println("发热后有没有吃退热药?");if(a[1][3]==0) {System.out.println("有吃退热药");}else if(a[1][3]==1) {System.out.println("没有吃退热药");}System.out.println("吃退热药后的体温情况是?");if(a[1][4]==0) {System.out.println("体温下降");}else if(a[1][4]==1) {System.out.println("体温下降又升高");}else if(a[1][4]==2) {System.out.println("体温没有下降");}break;case 3:System.out.println("有没有咳痰?");if(a[2][0]==0) {System.out.println("没");}else if(a[2][0]==1) {System.out.println("有");}break;case 6:System.out.println("有没有胸闷加重?");if(a[3][0]==0) {System.out.println("没");}else if(a[3][0]==1) {System.out.println("有");}break;case 7:System.out.println("有没有气急加重?");if(a[4][0]==0) {System.out.println("没");}else if(a[4][0]==1) {System.out.println("有");}break;case 11:System.out.println("有没有腹泻加重?");if(a[5][0]==0) {System.out.println("没");}else if(a[5][0]==1) {System.out.println("有");}break;}}System.out.println("本次不舒服有多久了");if(a[6][0]==0) {System.out.println("14天以内");}else{System.out.println("14天以上");}if(a[7][0]==0) {System.out.println("都没有");return 1;}return 0;}}

package studenttest.experiment1;import java.io.FileOutputStream;import java.io.OutputStreamWriter;import mons.csv.CSVFormat;import mons.csv.CSVPrinter;public class work4DataGenerate {private final static String destDir = "src/test/resources/";public static void main(String[] args) throws Exception {// 生成等价类测试testNormalValue();}public static void testNormalValue() throws Exception // Parameters!{FileOutputStream fos = new FileOutputStream(destDir + "等价类测试用例.csv");OutputStreamWriter osw = new OutputStreamWriter(fos, "utf-8");CSVFormat csvFormat = CSVFormat.DEFAULT.withHeader("用例编号", "a[0][0]", "a[0][1]", "a[0][2]", "a[0][3]","a[0][4]", "a[0][5]", "a[0][6]", "a[0][7]", "a[0][8]", "a[0][9]", "a[0][10]", "a[1][0]", "a[1][1]","a[1][2]", "a[1][3]", "a[1][4]", "a[2][0]", "a[3][0]", "a[4][0]","a[5][0]", "a[6][0]", "a[7][0]", "a[7][1]", "a[7][2]", "a[7][3]", "期望值");// 1+1+5+1+1CSVPrinter csvPrinter = new CSVPrinter(osw, csvFormat);int[][] a = {{-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 }, // 症状采集{-1, -1, -1, -1, -1 }, // 发烧(2,_,3,2,3,){-1 }, // 咳痰{-1 }, // 胸闷{-1}, // 气急{-1 }, // 腹泻{-1 }, // 本次不舒服{-1, -1, -1, -1 } };//for (int i = 0; i < 8; i++) {//for (int j = 0; j < 11; j++) {//a[i][j] = -1;//}//}a[0][0] = 0;a[7][0] = 0;// 检测全为0csvPrinter.printRecord(1, 0, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,-1, -1, -1, -1, 0, -1, -1, -1, 3);int num = 2;// 检测仅有接触史等for (int i = 1; i < 5; i++) {a[7][0] = i;csvPrinter.printRecord(num, 0, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, i, -1, -1, -1,2);num++;}a[7][0] = 1;a[7][1] = 2;a[7][2] = 3;a[7][3] = 4;csvPrinter.printRecord(num, 0, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 1, 2, 3, 4, 2);num++;// 检测仅有接触史等,发烧a[6][0]=0;a[7][0] = 0;a[7][1] = -1;a[7][2] = -1;a[7][3] = -1;a[0][0] = 1;a[1][0] = 0;//2a[1][1] = 373;a[1][2] = 0;//3a[1][3] = 0;//2a[1][4] = 0;//3csvPrinter.printRecord(num, 1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,0, 373, 0, 0, 0, -1, -1, -1, -1, 0, 0, -1, -1, -1, 1);num++;a[1][0] = 1;//2//a[1][1] = 373;a[1][2] = 1;//3a[1][3] = 1;//2a[1][4] = 1;//3csvPrinter.printRecord(num, 1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,1, 373, 1, 1, 1, -1, -1, -1, -1, 0, 0, -1, -1, -1, 1);num++;a[1][2] = 2;//3//a[1][3] = 1;//2a[1][4] = 2;//3csvPrinter.printRecord(num, 1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,1, 373, 2, 1, 2, -1, -1, -1,-1, 0, 0, -1, -1, -1, 1);num++;// 检测仅有接触史等,咳嗽a[1][0] = -1;//2a[1][1] = -1;a[1][2] = -1;//3a[1][3] = -1;//2a[1][4] = -1;//3a[0][0] = 3;a[2][0] = 0;csvPrinter.printRecord(num, 3, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,-1, -1, -1, -1, -1,0, -1, -1, -1, 0, 0, -1, -1, -1,1);num++;a[2][0] = 1;csvPrinter.printRecord(num, 3, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,-1, -1, -1, -1, -1,1, -1, -1, -1, 0, 0, -1, -1, -1, 1);num++;// 检测仅有接触史等,胸闷a[2][0] = -1;a[0][0] = 6;a[3][0] = 0;csvPrinter.printRecord(num, 6, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,-1, -1, -1, -1, -1,-1, 0, -1, -1, 0, 0, -1, -1, -1,1);num++;a[3][0] = 1;csvPrinter.printRecord(num, 6, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,-1, -1, -1, -1, -1,-1, 1, -1, -1, 0, 0, -1, -1, -1,1);num++;// 检测仅有接触史等,气急a[3][0] = -1;a[0][0] = 7;a[4][0] = 0;csvPrinter.printRecord(num, 7, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,-1, -1, -1, -1, -1,-1, -1, 0, -1, 0, 0, -1, -1, -1, 1);num++;a[4][0] = 1;csvPrinter.printRecord(num, 7, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,-1, -1, -1, -1, -1,-1, -1, 1, -1, 0, 0, -1, -1, -1,1);num++;// 检测仅有接触史等,腹泻a[4][0] = -1;a[0][0] = 11;a[5][0] = 0;csvPrinter.printRecord(num, 11, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,-1, -1, -1, -1, -1,-1, -1,-1, 0, 0, 0, -1, -1, -1, 1);num++;a[5][0] = 1;csvPrinter.printRecord(num,11, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,-1, -1, -1, -1, -1,-1, -1, -1,1, 0, 0, -1, -1, -1, 1);num++;//测试一个其他病,时间a[5][0] = -1;a[0][0] = 9;a[6][0]=1;csvPrinter.printRecord(num,9, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,-1, -1, -1, -1, -1,-1, -1, -1,-1, 1, 0, -1, -1, -1,1);num++;//测试一个其他病,时间a[7][0]=1;csvPrinter.printRecord(num,9, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,-1, -1, -1, -1, -1,-1, -1, -1,-1, 1, 1, -1, -1, -1,0);num++;csvPrinter.flush();csvPrinter.close();}}

import static org.junit.jupiter.api.Assertions.assertEquals;import org.junit.jupiter.api.DisplayName;import org.junit.jupiter.params.ParameterizedTest;import org.junit.jupiter.params.provider.CsvFileSource;import studenttest.experiment1.work4;class work4FromCSVFileTest {@ParameterizedTest@DisplayName("等价类测试用例")@CsvFileSource(resources = "/等价类测试用例.csv",numLinesToSkip=1)void testNormalBoundary(int num,int a0,int a1,int a2,int a3,int a4,int a5,int a6,int a7,int a8,int a9,int a10,int b0,int b1,int b2,int b3,int b4,int c0,int d0,int e0,int f0,int g0,int h0,int h1,int h2,int h3,int type) {int[][] a= {{a0, a1, a2, a3,a4, a5, a6, a7, a8, a9, a10},{b0,b1,b2,b3,b4},{c0},{d0},{e0},{f0},{g0},{h0,h1,h2,h3}};assertEquals(type,work4.classify(a));}}

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。