題目1:根據(jù)下列流程圖編寫程序?qū)崿F(xiàn)相應(yīng)分析處理并顯示結(jié)果。返回結(jié)果“a=x:”(x為2、3或4);其中變量x、y均須為整型。編寫程序代碼,使用JUnit框架編寫測(cè)試類對(duì)編寫的程序代碼進(jìn)行測(cè)試,測(cè)試類中設(shè)計(jì)最少的測(cè)試數(shù)據(jù)滿足語(yǔ)句覆蓋測(cè)試,每條測(cè)試數(shù)據(jù)需要在測(cè)試類中編寫一個(gè)測(cè)試方法。使用assertThat中equalTo斷言判斷期望結(jié)果值和實(shí)際返回值是否一致。
文章來(lái)源:http://www.zghlxwxcb.cn/news/detail-543598.html
被測(cè)試代碼段:文章來(lái)源地址http://www.zghlxwxcb.cn/news/detail-543598.html
package helian01;
public class demo01 {
private static String result;
public void math(int x,int y) {
if(x>=80&&y>=60) {
if(x>=90||y>=90) {
}else {
x=2;
String string = Integer.toString(x);
result ="a="+string;
}
}else {
if(x<=70||y<=70) {
x=3;
String string = Integer.toString(x);
re
到了這里,關(guān)于白盒測(cè)試(單元測(cè)試使用assertThat中equalTo斷言)的文章就介紹完了。如果您還想了解更多內(nèi)容,請(qǐng)?jiān)谟疑辖撬阉鱐OY模板網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關(guān)文章,希望大家以后多多支持TOY模板網(wǎng)!