- 以下哪个边界条件声明测试应该验证传递的输入值是否在变量范围内?
-
- 弓用
- 基数
- 范围
- 排序
-
- 有效测试的以下哪个属性声明测试用例不得依赖于其他测试用例或类?
-
- 专业
- 可重复
- 自动
- 独立
-
- 思考以下代码段
public double area(double radius)
{
return (3.14*radius*radius);
}
public double circumference(double radius)
{
return (2*3.14* radius);
}
编写测试时,仅为 area()方法内的语句创建了测试用例。运行 JaCoCo 代码覆盖工具后,以下哪个颜色将出现在circumference()方法内的语句上?
-
-
- 绿色
- 黄名
- 红色
- 白色
-
- oliver 开发了应用程序来通过以下代码段检查输入的年份是否闰年:
public boolean leapyear(int year)
{
if ((year % 400 == 0) || ((year % 4 == 0) && (year % 100 != 0)))
{
return true:
}
else
{
return false;
}
}
…..
@Test
public void testLeapyear0) {
System.out. printIn("leapyear");
int year = 2000;
Year instance = new Year();
boolean expResult = true;
boolean result = instance.leapyear(year);
assertEquals(expResult, result);
}
上述试验条件不能产生正确的结果。从给定的选项中找到正确的测试函数?
-
- @Test
public void testLeapyear() {
System.out. println("leapyear");
int year = 2004:
Year instance = new Year();
boolean expResult = false;
boolean result = instance.leapyear(year);
assertEquals(expResult, result);
}
-
- @Test
public void testLeapyear(){
System.out. println ("leapyear");
int year = 2004;
Year instance = new Year();
boolean expResult = true;
boolean result = instance.leapyear(year);
assertEquals(result,expResult );
}
-
- @Test
public void testLeapyear() {
System.out. println("leapyear");
int year = 1996;
Year instance = new Year();
boolean expResult = false;
boolean result = instance.leapyear(year);
assertEquals(expResult, result);
}
-
- @Test
public void testLeapyear() {
System.out. println("leapyear*);
int year = 1700;
Year instance
= new Year();
boolean expResult = false:
boolean result = instance.leapyear(year);
assertEquals(expResult, result);
}
- 以下哪个cron 语法将用于在每 10 分钟以后构建一个模块?
- 10/H****
- H***10
- H/10****
- **H/10**
- 以下哪个类型的项目将项目构建为任何形式(例如shell 脚本、ant 项目或 dos 脚本)?
- 自由样式项目
- Maven 项目
- 外部作业
- 构建多配置项目
- Tobby 需要使用数据驱动的测试来测试数据库与应用程序的连接。他创建了输入数据文件。测试期间,他希望从数据库表中删除数据文件中提供的所有行。他将使用以下哪个数据库操作满足需求?
- DatabaseOperation.DELETE_ALL
- DatabaseOperation.INSERT
- DatabaseOperation.CLEAN_INSERT
- DatabaseOperation.REFRESH
- sam 创建了Web 应用程序并希望通过对数据库表执行 RLFRESH 操作来测试它与数据库的连接。他希望操作在任何测试执行前执行。他应该使用以下哪个选项来定义 REFRESH 操作?
- @Override
protected DatabaseOperation getTearDownOperation() throws Exception{
return DatabaseOperation.REFRESH;}
-
- @Override
protected DatabaseOperation getSetUpOperation() throws Exception{
return DatabaseOperation.REFRESH:}
-
- @Override
protected DatabaseOperation getTearDownOperation() throws Exception{
return REFRESH;}
-
- @Override
protected DatabaseOperation getTearDownOperation() throws Exception{
return DatabaseOperation.CLEAN_INSERT;}
- JUnit框架中的以下哪个元素是执行以测试应用程序的一个或多个测试用例或测试套件的集合?
- 测试用例
- 测试运行器
- 测试
- 测试结果
- web 应用程序的个别单元正在被集成和测试以验证整体功能。此用例中 用了哪个测试级别?
- 系统测试
- 性能测试
- 集成测试
- 验收测试
- Linda 希望创建 MystockMarket 类的普通模拟对象。以下哪个选项将帮助她满足此需求?
- myStockMarketMock= EasyMock.createMock(MyStockMarket.class);
- myStockMarketMock=EasyMock.createNiceMock(MyStockMarket.class);
- myStockMarketMock=EasyMock.createMock(MyStockMarket);
- myStockMarketMock=EasyMock.createNiceMock(MyStockMarket);
- Linda 使用 EasyMock 框架创建了模拟对象myStockMarketMock。她希望指定何时应该执行 myStockMarketMock 模批对象的方法。以下哪个选项将满足她的需求?
- EasyMock.verify(myStockMarketMock);
- EasyMock.when(myStockMarketMock);
- EasyMock.replay(myStockMarketMock);
- EasyMock.expect(myStockMarketMock);
- Sam 正在为 web 应用程序创建测试用例。他希望他的方法在类中的任一测试方法之前运行一次,他需要在此方法上使用什么批注?
- @BeforeClass
- @Before
- @After
- @AfterClass
- Harry 希望验证某文本在其网站上的外观。他将在 Response Assertion 的 Response Field to Test 部分选择以下哪个选项?
- URL样本
- 响应报头
- 文本响应
- Please add choice 4
- Oliver 希望对 Bing 网站执行负载测试并查看摘要报告中的结果。为此,他向测试计划添加了样本 HTTP 请求。他需要在以下哪个字段中指定 Bing 网站的 URL?
- 路径
- 端口号
- 名称
- 编码
- JWebUnit 类的以下哪个方法用于测试给定名称或 Id 的表单在当前窗口中是否存在?
- assertLabelPresent(String id)
- assertFormPresent()
- assertElementPresent(String anID)
- assertFormPresent (String nameOrID)
- 以下哪个测试策略测试软件的整体功能,不测试代码中的每个语句和分支?
- 回归测试
- 黑盒测试
- 白盒测试
- 性能测试
- 以下哪个选项描述一个类,其中包括自动逐个执行的不同测试类?
- 测试结果
- 测试运行器
- 测试套件
- 测试用例
- STLC的以下哪个阶段包括设置方便而顺畅地执行测试所必须的必要工具和基础结构?
- 测试环境设置
- 需求分析
- 测试规划
- 测试执行
- 以下哪个测试类型确保个别单元是可靠无错的?
- 集成测试
- 系统测试
- 验收测试
- 单元测试
- Junit架构的以下哪个元素是Junit测试的最小单元,用于验证所测试方法的功能?
- 测试用例
- 测试套件
- 测试
- 测试运行期
- Junit架构的以下哪个元素将在执行测试时在后台执行以显示测试结果(通过或者不通过)?
- 测试结果
- 测试运行期
- 测试
- 测试套件
- 以下哪个批注使它所连接到的方法在测试方法之前运行?
- @Before
- @BeforeClass
- @After
- @AfterClass
- 哪个Junit断言语句检查期望值和实际值是否相同?
- assertTrue()
- assertFalse()
- assertEquals()
- assertEqual()
- 以下哪个注解与expected属性一起使用
- @AfterClass
- @Test
- @BeforeClass
- @Before
- 以下哪个Exception类用于处理程序执行期间发生的异常?
- IllegalArgumentException
- AssertError
- RuntimeException
- StackOverflowError
- Junit在@Test注解内提供一下哪个属性以检查方法是否在指定时间内返回所需输出?
- timeout
- timeOut
- excepted
- expect
- 以下哪个选项允许用户在单个测试用例中作为参数传递和运行多组输入和期望值?
- 参数化测试
- @Parameter注解
- @RunWith(Suite.class)注解
- @RunWith(Parameterized.class)注解
- 以下哪个文本匹配器将在实际结果以指定字符串结尾的情况下匹配?
- containsString()
- endsWith()
- startsWith()
- equalToIgnoringCase()
- 需要使用以下哪个注解来标注测试类以创建测试套件?
- @RunWith()
- @RunWith(Parameterized.class)
- @RunWith(Suite.class)
- @Suite.SuiteClasses()
- 需要使用以下哪个注解指定希望成为测试套件一部分的测试类的引用?
- @RunWith()
- @RunWith(Parameterized.class)
- @Suite.SuiteClasses()
- @Suite.SuiteClass()
- 以下哪个逻辑匹配器测试是否有任何匹配器匹配目标对象,或者至少一个匹配器匹配目标对象?
- allOf()
- anyOf()
- anyof()
- not()
- 以下哪个集合匹配器测试包含元素的数组?
- array()
- hasItem()
- hasItemArray()
- hasItemInArray()
- 以下哪个数字匹配器测试所检查对象是否小于指定的期望值?
- lessThan()
- lessThen()
- lessThanEqualTo()
- lessThanOrEquualTo()
- 以下哪个代码覆盖指标确保测试了代码中的每个语句?
- 语句涵盖
- 函数覆盖
- 循环覆盖
- 条件覆盖
- 以下哪个颜色指示由测试用例部分覆盖的代码区域?
- 绿色
- 黄色
- 红色
- 白色
-------------------------------------------------------------------------------------------------------------------------------------------------------
- 以下哪个断言语句检查对于float和double类型的值,期望值和实际值是否相同?
- assertEquals([message] , expected , actual )
- assertSame([message] , expected , actual )
- assertEquals([message] , expected , actual ,tolerance )
- assertNoSame([message] , expected , actual )
- 哪个模拟对象要求带测模块中的所有期望方法以任意顺序带指定参数运行调用,并且对非期望方法的调用不会引起测试不通过?
- 随意
- 正常
- 严格
- 实际
- 以下哪个批注使它所连接的方法在测试方法之前运行?
- @Before
- @After
- @BeforeClass
- @AfterClass
- 您将使用以下哪个选项模拟具有指定标题的按钮的Click事件?
- clickButtonWithText(String buttonText)
- clickButton(String buttonId)
- submit()
- Submit(String buttonName)
- 以下哪个Hamcrest匹配器将在给定对象是与另一个对象完全相同的实例时匹配?
- instanceOf
- sameInstance
- hasItem
- closeTo
- 您开发了应用程序以根据学生百分制分数来推断学生表现。例如,分数在30-50分之间的学生被认定为通过并得到等级D,而分数在29分以下的学生被认定为不通过并得到等级E。现在你希望确保当你将29分作为待测方法的输入时,应该返回等级E。以下那个边界条件帮助您确保实现以上需求?
- 基数
- 符合性
- 范围
- 排序
- Web应用程序的个别单元正在被集成和测试以验证整体功能。此用例引用了哪个测试级别?
- 系统测试
- 性能测试
- 集成测试
- 验收测试
- 您为一所学院开发了应用程序以管理器学生数据。此应用程序的开发将很快开始,您被分配的任务时准备不同数据文中的输入和期望数据。数据驱动测试的以下哪个优点将确保您能够执行分配的任务?
- 需要了解脚本语言
- 降低了测试用例中的冗余
- 需要结构化数据文件
- 独立测试脚本
- 正在测试Web应用程序以识别已修改代码中的错误。此用例中引用了哪个测试级别?
- 回归测试
- 性能测试
- 集成测试
- 系统测试
- Emily开发了使用MySQL数据库的雇员管理应用程序。在此程序中她创建了多个网页、类和数据库表。开发以后,Emily希望测试应用程序并验证UI表单的正确元素是否与数据库表的所需列进行连接。数据库测试的以下哪个好处确保符合以上需求?
- 可管理的记录
- 数据映射
- 数据完整性
- 独立测试脚本
- Sam开发了基本的计算器应用程序,为除法方法编写测试时,他希望创建的测试用例能够处理除以0时生成的异常。以下哪个选项将符合此需求?
- @Test(expected = ArithmeticException.class)
Public void testDivide(){
Calculator instance = new Calculator ();
Instance.divide( 4 , 0 );
}
- @Test(expected = AssertionError.class)
Public void testDivide(){
Calculator instance = new Calculator ();
Instance.divide( 4 , 0 );
}
- @Test(expected = RuntimeException.class)
Public void testDivide(){
Calculator instance = new Calculator ();
Instance.divide( 4 , 0 );
}
- @Test(expected = StackOverflowError.class)
Public void testDivide(){
Calculator instance = new Calculator ();
Instance.divide( 4 , 0 );
}
- 您被要求使用以下测试场景为Palindrome类创建测试用例:
- 回文字符串
- 非回文字符串
为此,您创建了以下测试用例:
@Test
public void testPal1(){
Boolean expected = true;
Boolean result = Palindrome.isPalindrome(“bob”);
assertEquals(expected , result );
}
@Test
public void testPal2(){
Boolean expected = false;
Boolean result = Palindrome.isPalindrome(“bat”);
assertEquals(expected , result );
}
现在,您被要求为此此时用例创建所需的逻辑,因为您正在使用TDD开发此应用程序,您将使用以下哪个代码来创建使以上测试用例能够通过的所需代码?
- Public class Palindrome{
public static Boolean isPalindrome(String str){
int len = str.length();
Boolean flag = true;
for( j = 0 ; j < len/2 ; j ++){
if ( str[ j ] != str[ len -1 -j ]){
Break;
} }
return flag ;
} }
- Public class Palindrome{
public static Boolean isPalindrome(String str){
int len = str.length();
Boolean flag = true;
for( j =len ; j < 0 ; j - -){
if ( str[ j ] != str[ len -1 - j ]){
break;
} }
return flag ;
} }
- Public class Palindrome{
public static Boolean isPalindrome(String str){
int len = str.length();
Boo;ean flag = true;
for( j = len ; j < len/2 ; j ++){
if ( str[ j ] != str[ len -1 ] ){
flag = false ;
break;
} }
return flag ;
} }
- Public class Palindrome{
public static Boolean isPalindrome(String str){
int len = str.length();
Boolean flag = true;
for( j = 0 ; j < len/2 ; j ++){
if ( str[ j ] != str[ len -1 - j ]){
flag = false ;
break;
} }
return flag ;
} }
- Sam创建了应用程序以通过以下代码衡量学生表现:
Public String Performance( double marks ){
If ( marks >= 70 && marks <=100 ){
return “Excellent”;
}else if ( marks >=50 && marks <=69 ){
Return “Average”;
}else if ( marks >=0 && marks <=49 ){
Return “Bad”;
}else {
Return “Invalid value”;
} }
他编写了以下代码测试以上代码:
.....................
@Test
public viud testPerformance(){
System.out.println(“Performance”);
Double marks = 80 ;
StudentPerformance instance =new StudentPerformance();
String expResult =”Excellent”;
String result = instance.performance( marks );
assertEquals(expResult , result );
}
@Test
public viud testPerformance2(){
System.out.println(“Performance”);
Double marks = 6 0;
StudentPerformance instance =new StudentPerformance();
String expResult =”Average”;
String result = instance.performance( marks );
assertEquals(expResult , result );
}
..........
但是他无法实现100%代码覆盖。以下哪个测试用例将帮助他实现100%代码覆盖?
A.@Test
public viud testPerformance(){
System.out.println(“Performance”);
Double marks = 35 ;
StudentPerformance instance =new StudentPerformance();
String expResult =”Bad”;
String result = instance.performance( marks );
assertEquals(expResult , result );
}
@Test
public viud testPerformance2(){
System.out.println(“Performance”);
Double marks = 150;
StudentPerformance instance =new StudentPerformance();
String expResult =”Invalid value”;
String result = instance.performance( marks );
assertEquals(expResult , result );
}
B.@Test
public viud testPerformance(){
System.out.println(“Performance”);
Double marks = 35 ;
StudentPerformance instance =new StudentPerformance();
String expResult =”Bad”;
String result = instance.performance( marks );
assertEquals(expResult , result );
}
- @Test
public viud testPerformance(){
System.out.println(“Performance”);
Double marks = 150 ;
StudentPerformance instance =new StudentPerformance();
String expResult =”Invalid value”;
String result = instance.performance( marks );
assertEquals(expResult , result );
}
- @Test
public viud testPerformance(){
System.out.println(“Performance”);
Double marks = 90 ;
StudentPerformance instance =new StudentPerformance();
String expResult =”Excellent”;
String result = instance.performance( marks );
assertEquals(expResult , result );
}
@Test
public viud testPerformance2(){
System.out.println(“Performance”);
Double marks = 150;
StudentPerformance instance =new StudentPerformance();
String expResult =”Invalid value”;
String result = instance.performance( marks );
assertEquals(expResult , result );
}
- Linda希望测试一个servlet,她向pom.xml文件添加了服务器属性。现在她需要在pom.xml文件中添加服务器依赖。以下哪个选项将帮助她满足满足?
glassfish-embedded-static-shell
............
glassfish-embedded-static-shell
............
glassfish-embedded-static-shell
............
glassfish-embedded-static-shell
............
- Harry开发了一个阶乘应用程序,他希望填写测试用例以处理用户输入负数时产生的异常。以下哪个选项将满足他的需求?
- @Test(expected = IllegalArgumentException.class)
Public void testFactorial(){
Factorial instence = new Factorial();
Instance.fact(-4);
}
- @Test(expected = ArithmeticException.class)
Public void testFactorial(){
Factorial instence = new Factorial();
Instance.fact(-4);
}
- @Test(expected =RuntimeException.class)
Public void testFactorial(){
Factorial instence = new Factorial();
Instance.fact(-4);
}
- @Test(expected = StackOverflowException.class)
Public void testFactorial(){
Factorial instence = new Factorial();
Instance.fact(-4);
}
- Sam开发了EJB模块以将距离转换为不同单位,如千米、米、英里。现在他需要测试该模块。为此Sam在pom.xml文件中编写了以下代码以添加服务器属性:
现在他需要添加服务器依赖。Sam应该使用以下哪个代码显示以上需求?
glassfish-embedded-static-shell
glassfish-embedded-static-shell
glassfish-embedded-static-shell
glassfish-embedded-static-shell
- George开发了应用程序以通过以下代码返回三个数中的最大数:
Public class Larget{
Public int largest( int a, int b , int c){
If ( a>b && a>c){
return a;
}else if ( b>a && b>c){
return b;
}else{
return c;
} }
Public static void main(String[] args){
}
}
现在他需要创建测试用例以处理用户输入字符串值的异常情况。以下哪个选项成功处理异常?
- @Test(expected =RuntimeException.class)
Public void testLargest(){
System.out.println(“ largest handles the exception”);
Int a = 12 ;
String b = “abcd”;
Int c = -39;
Largest instence = new Largest();
Int expResult = 12;
Int result = instence.largest( a ,b , c );
assertEquals( expResult , result );
}
- @Test(expected =RuntimeException.class)
Public void testLargest(){
System.out.println(“ largest handles the exception”);
Int a = 12 ;
Int b = 5;
Int c = -39;
Largest instence = new Largest();
Int expResult = 12;
Int result = instence.largest( a ,b , c );
assertEquals( expResult , result );
}
- @Test(expected = ArithmeticException.class)
Public void testLargest(){
System.out.println(“ largest handles the exception”);
Int a = 12 ;
Int b = “abcd”;
Int c = -39;
Largest instence = new Largest();
Int expResult = 12;
Int result = instence.largest( a ,b , c );
assertEquals( expResult , result );
}
- @Test(expected =ArithmeticException.class)
Public void testLargest(){
System.out.println(“ largest handles the exception”);
Int a = 12 ;
Int b = 5;
Int c = -39;
Largest instence = new Largest();
Int expResult = 12;
Int result = instence.largest( a ,b , c );
assertEquals( expResult , result );
}
- Allen 开发了一个应用程序以通过以下代码接受一个数字并返回该数字各位的和:
Public class SumDigits{
Public int sum( int num){
Int sum = 0 ;
While( num > 0 ) {
sum = sum + num%10 ;
num = num/10 ;
}
return sum ;
}
Public static void main(String[] args){
}
}
现在他需要创建测试用例以处理用户输入小数值的异常情况。以下哪个选项成功处理异常?
- @Test(expected =RuntimeException.class)
Public void testSum(){
System.out.println(“ sum handles the exception”);
Int num= 253 ;
SumDigits instence = new SumDigits();
Int expResult = 10;
Int result = instence.sum( num );
assertEquals( expResult , result );
}
- @Test(expected =IllegalArgumentException.class)
Public void testSum(){
System.out.println(“ sum handles the exception”);
Int num= 253 ;
SumDigits instence = new SumDigits();
Int expResult = 10;
Int result = instence.sum( num );
assertEquals( expResult , result );
}
- @Test(expected =IllegalArgumentException.class)
Public void testSum(){
System.out.println(“ sum handles the exception”);
Int num= 253.34 ;
SumDigits instence = new SumDigits();
Int expResult = 10;
Int result = instence.sum( num );
assertEquals( expResult , result );
}
- @Test(expected =RuntimeException.class)
Public void testSum(){
System.out.println(“ sum handles the exception”);
double num= 253.34;
SumDigits instence = new SumDigits();
Int expResult = 10;
Int result = instence.sum( num );
assertEquals( expResult , result );
}
- George 为旅行社开发了一个网站,其中包含各个页面,例如HomePage、LoginPage、RegistrationPage和AdminPage。LoginPage页面使用用户能够通过有效凭证作为管理员或者作为客户登陆。开发后,George需要测试LoginPage并验证组件(例如文本框username和password,用于选择管理员和客户的单选按钮,以及用于提交和重置功能的按钮)在页面上是否可用。为此,他编写了以下代码:
@Test
Public void testPageComponents(){
beginAt(“ / HomePage.jsp ”);
assertTitleEquals(“ Login Page”);
assertFormElementPresent(“ textboxes ”);
assertRadioOptionPresent(“ administrator” , “ customer”);
assertButtonPresentWithText(“ Submit ”);
}
然而,上述代码未满足指定的测试需求。George 应该使用以下哪个代码解决此问题?
- @Test
Public void testPageComponents(){
beginAt(“ / HomePage.jsp ”);
assertTitleEquals(“ Login Page”);
assertFormElementPresent(“ username ”);
assertFormElementPresent(“ password ”);
assertRadioOptionPresent(“ rBtn1” , “ administrator”);
assertRadioOptionPresent(“ rBtn1” , “ customer”);
assertButtonPresentWithText(“ Submit ”);
assertResetButtonPresent();
}
- @Test
Public void testPageComponents(){
beginAt(“ / LoginPage.jsp ”);
assertTitleEquals(“ Login Page”);
assertFormElementPresent(“ username ”);
assertFormElementPresent(“ password ”);
assertRadioOptionPresent(“ rBtn1” , “ administrator”);
assertRadioOptionPresent(“ rBtn1” , “ customer”);
assertButtonPresentWithText(“ Submit ”);
assertResetButtonPresent();
}
- @Test
Public void testPageComponents(){
beginAt(“ / LoginPage.jsp ”);
assertTitleEquals(“ Login Page”);
assertFormElementPresent(“ username ”);
assertRadioOptionPresent(“ rBtn1” , “ administrator”);
assertRadioOptionPresent(“ rBtn1” , “ customer”);
assertButtonPresentWithText(“ Submit ”);
assertResetButtonPresent();
}
- @Test
Public void testPageComponents(){
beginAt(“ / LoginPage.jsp ”);
assertTitleEquals(“ Login Page”);
assertFormElementPresent(“ username ”);
assertFormElementPresent(“ password ”);
assertRadioOptionPresent(“ rBtn1” , “ administrator”);
assertRadioOptionPresent(“ rBtn1” , “ customer”);
assertButtonPresentWithText(“ Submit ”);
}
- Samantha 创建了应用程序以维护出版物作者的详细信息。在此应用程序中,她创建了Servet以验证登陆详细信息并将作者重定向到相应页面。现在您需要使用Mockito框架测试Servlet功能。为此您使用以下代码在pom.xml文件中添加了依赖:
easymock
glassfish-embedded-static-shell
easymock
glassfish-embedded-static-shell
mockito-all
glassfish-embedded-static-shell
mockito-all
glassfish-embedded-static-shell
-------------------------------------------------------------------------------------------------------------------------------------------------------
21.Debug透视图的_____选项卡显示当前正在应用中运行的线程。
A.Debug
B.Variables
C.Breakpoints
D.LogCat
22.以下哪个布局用于以堆栈格式从下网上添加视图?
A.框架布局
B.表格布局
C.线性布局
D.绝对布局
23.Ria基于Android平台创建了赛车应用,当她执行应用时,发现用户进入游戏的下一个级别时分数不增加,她决定使用“调试”透视图调试应用,“调试”透视图的以下哪个选项卡将允许她查看与针对分数存储的值相关的信息?B
A.LogCat选项卡
B."变量"选项卡
C."断点"选项卡
D."调试"选项卡
24.您需要模拟那些类和接口来对Servlet进行单元测试?
A.HttpServletrequest,HttpServletResponse,HttpSession,ServletOutputStream
B.HttpServletResponse,HttpSession
C.HttpServletRequest,HttpSession
D.HttpSession,ServletOutputStream
25.以下哪个Hamcrest匹配器将在实际结果包含指定字符串的情况下匹配?
A.containsString
B.hasItem
C.allOf
D.closeTo
26.您为一所学校开发了应用程序以管理其学生数据,此应用程序的开发将很快开始,您被分配的任务是准备不同数据文件中的输入和期望数据,数据驱动测试的以下哪个优点将确保您能够执行分配的任务?
A.需要了解脚本语言
B.降低了测试用例中的冗余
C.需要结构化数据文件
D.独立测试脚本
27.您开发了应用程序以打印一直到n的素数,其中n是用户输入的数字,现在您希望验证用于显示素数的该循环是否执行了n次,以下哪个边界条件将帮助您确保实现以上需求?B----------
A.基数
B.符合性
C.范围
D.排序
28.Web应用程序的个别单元正在被集成和测试以验证整体功能,此用例中引用了哪个测试级别?C
A.系统测试
B.性能测试
C.集成测试
D.验收测试
29.Emily开发了使用MySQL数据库的雇员管理应用程序,在此应用程序中,她创建了多个网页,类和数据库表,开发以后,Emily希望测试应用程序并验证UI表单的正确元素是否与数据库表的所需列进行链接,数据库测试的以下哪个好处确保符合以上需求?C------------
A.可管理的记录
B.数据映射
C.数据完整性
D.独立测试脚本
30.John开发了学生管理应用程序,其中包含网页、类和数据库表,开发后,John希望对应用程序执行数据驱动的测试,为此,他创建了数据文件并向其中添加了以下代码段:
John使用了以下哪个格式创建以上数据文件?C----------
A.xml
B.xlsx
C.csv
D.txt
31.您被分配的任务是使用TDD方法开发计算器应用程序,您在使用TDD方法开发应用程序时,需要遵循以下哪个步骤序列?
A. I.编写代码
II.编写测试场景
III.将测试场景实现到测试用例中
IV.运行测试
B. I.编写测试场景
II.将测试场景实现到测试用例中
III.编写代码
IV.运行测试
C. I.编写测试场景
II.将测试场景实现到测试用例中
III.编写代码并运行测试
IV.从非功能的方面重构代码
D. I.编写测试场景
II.将测试场景实现到测试用例中
III.编写代码
IV.从非功能的方面重构代码,然后运行测试。
32.John创建了一个web应用程序,其中包含一个Servlet以检查用户凭证的正确性将用户重定向到某个页面。在此应用程序中,他添加了Products.jsp页面,现在他希望在直接访问此页面的情况下,用户应该被重定向到登录页面。为此,他使用以下代码段在应用程序中创建了过滤器:
public class MyFilter implements Filter{
@Override
public ovid doFilter(ServletRequest request,ServletResponse response,FilterChain chain) throws IOException,ServletException{
HttpServletRequest servletRequest = (HttpServletRequest) request;
HttpServletResponse servletResponse =(HttpServletResponse) response;
String currentURL = servletRequest.getRequestURI();
chain.doFIlter(request,response);
if(currentURL.equals("/ServletFilterUnitTest_Mockito/Products.jsp")){
servletResponse.sendRedirect("/ServletFilterUnitTest_Mockito/");
}
}
@Override
public void init(FilterConfig config)throws ServletException{
String testParameter = config.getInitParameter("test-param");
}
@Override
public void destroy(){
//Release any resource
}
}
现在他需要使用Mockito框架测试以上过滤器,他将使用以下哪个选项满足需求?
A. @Test
public void testDoFIlterMethod()throws Exception{
HttpServletRequest mockHttpServletRequest = mock(HttpServletRequest.class);
FIlterChain mockFilterChain = mock(FilterChain.class);
when(mockHttpServletRequest.getRequestURI()).thenReturn("/ServletFilterUnitTest_Mockito/Products.jsp");
MyFIlter myFilter = new MyFilter();
myFilter.doFilter(mockHttpServletRequest,mockHttpServletResponse,mockFilterChain);
verify(mockHttpServletRequest,atLeast(1)).getRequestURI();
verify(mockHttpServletResponse).sendRedirect("/ServletFilterUnitTest_Mockito/login.jsp");
}
B. @Test
public void testDoFilterMethod() throws Exception{
HttpServletRequest mockHttpServletRequest = mock(HttpServletRequest.class);
HttpServletResponse mockHttpServletResponse = mock(HttpServletResponse.class);
when(mockHttpServletRequest.getRequestURI()).thenReturn("/ServletFilterUnitTest_Mockito/Products.jsp");
MyFIlter myFilter = new MyFilter();
myFilter.doFilter(mockHttpServletRequest,mockHttpServletResponse,mockFilterChain);
verify(mockHttpServletRequest,atLeast(1)).getRequestURI();
verify(mockHttpServletResponse).sendRedirect("/ServletFilterUnitTest_Mockito/login.jsp");
}
C. @Test
public void testDoFilterMethod() throws Exception{
HttpServletRequest mockHttpServletRequest = mock(HttpServletRequest.class);
HttpServletResponse mockHttpServletResponse = mock(HttpServletResponse.class);
FIlterChain mockFilterChain = mock(FilterChain.class);
when(mockHttpServletRequest.getRequestURI()).thenReturn("/ServletFilterUnitTest_Mockito/Products.jsp");
MyFIlter myFilter = new MyFilter();
myFilter.doFilter(mockHttpServletRequest,mockHttpServletResponse);
verify(mockHttpServletRequest,atLeast(1)).getRequestURI();
verify(mockHttpServletResponse).sendRedirect("/ServletFilterUnitTest_Mockito/login.jsp");
}
D. @Test
public void testDoFilterMethod() throws Exception{
HttpServletRequest mockHttpServletRequest = mock(HttpServletRequest.class);
HttpServletResponse mockHttpServletResponse = mock(HttpServletResponse.class);
FIlterChain mockFilterChain = mock(FilterChain.class);
when(mockHttpServletRequest.getRequestURI()).thenReturn("/ServletFilterUnitTest_Mockito/Products.jsp");
MyFIlter myFilter = new MyFilter();
myFilter.doFilter(mockHttpServletRequest.mockHttpServletResponse,mockFilterChain);
verify(mockHttpServletRequest,atLeast(1)).getRequestURI();
verify(mockHttpServletResponse).sendRedirect("/ServletFilterUnitTest_Mockito/login.jsp");
}
33.George使用以下代码段创建了Web应用程序以计算复利:
public double COmpoundInterest(double principal,double rate,double time,double n){
if(principal>=0 && rate >=0 && time >= 0 && n>0){
double part1,part2,ci;
part1 = 1+(rate/n);
part2 = Math.pow(part1,time);
ci = principal*part2;
return ci;
}
return 0;
}
他编写了以下代码以测试以上代码:
-----------
-----------
@Test
public void testCompoundInterset(){
System.out.println("CompoundInterest");
double principal = 1000;
double rate = 0.05;
double time = 2;
double n = 2;
Interset instance = new Interest();
double expResult = 1050.625;
double result = instance.CompoundInterest(principal,rate,time,n);
assertEquals(exresult,result,0.5);
}
------
-----
但是,他无法实现100%代码覆盖率,以下哪个测试用例将帮助他实现100%代码覆盖率?
A. public void testCompoundInterest2(){
System.out.println("CompoundInterest");
double principal = 1698.45;
double rate = 0.058;
double time = 4.4;
double n = 3;
Interest instance = new Interest();
double expResult = 1847.75;
double result = instance.CompoundInterest(principal,rate,time,n);
assertEquals(expResult,result,0.5);
}
B. public void testCompoundInterest2(){
System.out.println("CompoundInterest");
double principal = 1598.45;
double rate = 0.058;
double time = 4.2;
double n = 3;
Interest instance = new Interest();
double expResult = 1732.31;
double result = instance.CompoundInterest(principal,rate,time,n);
assertEquals(expResult,result,0.5);
}
C. public void testCompoundInterest2(){
System.out.println("CompoundInterest");
double principal = 1000;
double rate = 0.05;
double time = -2;
double n = 2;
Interest instance = new Interest();
double expResult = 0;
double result = instance.CompoundInterest(principal,rate,time,n);
assertEquals(expResult,result,0.0);
}
D. public void testCompoundInterest2(){
System.out.println("CompoundInterest");
double principal = 1698.45;
double rate = 0.058;
double time = 4.4;
double n = 4;
Interest instance = new Interest();
double expResult = 1809.51;
double result = instance.CompoundInterest(principal,rate,time,n);
assertEquals(expResult,result,0.5);
}
34.Oliver开发了应用程序来通过以下代码段检查输入的年份是否闰年:
public boolean leapyear(int year){
if((year%400==0)||(year%4==0)&&(year%100!=0)){
return true;
}else{
return false;
}
}
他编写了以下代码段以测试以上代码:
----
@Test
public void testLeapyear(){
System.out.println("leapyear");
int year = 2000;
Year instance = new Year();
boolean expResult = true;
boolean result = instance.leapyear(year);
assertEquals(expResult,result);
}
但是,他无法实现100%代码覆盖率。以下哪个测试用例将帮助他实现100%代码覆盖率?C
A. public void testLeapyear2(){
System.out.println("leapyear");
int year = 2004;
Year instance = new Year();
boolean expResult = false;
boolean result = iinstance.leapyear(year);
assertEqueals(expResult,result);
}
B. public void testLeapyear2(){
System.out.println("leapyear");
int year = 2004;
Year instance = new Year();
boolean expResult = true;
boolean result = iinstance.leapyear(year);
assertEqueals(expResult,result);
}
C. public void testLeapyear2(){
System.out.println("leapyear");
int year = 1996;
Year instance = new Year();
boolean expResult = true;
boolean result = iinstance.leapyear(year);
assertEqueals(expResult,result);
}
D. public void testLeapyear2(){
System.out.println("leapyear");
int year = 1700;
Year instance = new Year();
boolean expResult = false;
boolean result = iinstance.leapyear(year);
assertEqueals(expResult,result);
}
35.Sam为求职门户开发了注册模块,在此应用程序中,他在Registration类中创建了registration()方法,此注册模块依赖于尚未就绪的部件模块的mail()方法,因此,要测试注册模块,他需要为邮件中模块创建桩模块,并且向注册模块返回肯定性的确认消息,他将使用以下哪个代码段创建桩模块类?
A.public class JobPortaiStub{
public boolean mail(){
return false;
}
}
B.public class JobPortaiStub{
public boolean registration(){
return false;
}
}
C.public class JobPortalStub{
public boolean registration(){
return true;
}
}
D.public class JobPortalStub{
public boolean mail(){
return true;
}
}
36.Taylor开发了Employee类以定义两个方法writeEmployeeData()和readEmployeeData().这些方法调用WriteEmployee类的writeData()和readData()和readData()方法。Taylor需要测试Employee类。然而,WriteEmoloyee类未实现用于读写数据的逻辑,因此,为了表示该类,可为writeData()
和readData()方法创建桩模块。为了确保测试成功通过,需要分别从writeData()和readData()方法返回字符串值Success和Employee Data。他将使用以下哪个选项为writeData()和readData()方法,因此,要测试注册模块,他需要为邮件中模块创建桩模块,并且向注册模块返回肯定性的确认消息,他将使用以下哪个代码段创建桩模块类?
A. public class WriteEmoloyeeStub implements IEmploueeDataWriter{
public String wirteData(Employee e){
return "Employee Data";
}
public String readData(){
return "Success";
}
}
B. public class WriteEmployeeStub implements IEmployeeDataWriter{
public String writeData(Employee e){
return "Success"
}
}
C. public class WriteEmployeeStub implements IEmployeeDataWriter{
public String writeData(Employee e){
return "EMployee Data";
}
}
D. public class WriteEmployeeStub implements IEmployeeDataWriter{
public String writeData(Employee e){
return "success";
}
public String readData(){
reuturn "Employee Data";
}
}
37.Sam开发了EJB模块以将距离转换为不同单位,例如千米、米和英里。现在他需要测试该模块。为此,Sam在pom。xml文件中编写了以下代码段以添加服务器属性:
现在他需要添加服务器依赖,Sam应该使用以下哪个代码段实现以上需求?
A.
B.
glassfish-embedded-static-shell
C.
glassfish-embedded-static-shell
D.
glassfish-embedded-static-shell
38.Emma开发了一个使用MySQL数据库的书籍管理应用程序。开发后,她希望使用DbUnit测试此应用程序。她希望在测试用例开始时删除现有值并将输入文件中指定的新值插入到数据库。然而,不希望在测试用例结束时执行任何操作。为此,她便下了以下代码段:
protected DatabaseOPeration getSetupOpeartion() throws Exception{
return DatabaseOperation.REFRESH;
}
protected DatabaseOPeration getSTearDownOpeartion() throws Exception{
return DatabaseOperation.DELETE_ALL;
}
但是,上述代码段未按预期执行,她应该使用以下哪个代码段实现以上需求?
A. protected DatabaseOperation getSetUpOperation() throws Exception{
return DatabaseOperation.REFRESH;
}
protected DatabaseOPeration getSTearDownOpeartion() throws Exception{
return DatabaseOperation.NONE;
}
B. protected DatabaseOperation getSetUpOperation() throws Exception{
return DatabaseOperation.INSERT;
}
protected DatabaseOPeration getSTearDownOpeartion() throws Exception{
return DatabaseOperation.NONE;
}
C. protected DatabaseOperation getSetUpOperation() throws Exception{
return DatabaseOperation.CLEAN_INSERT;
}
protected DatabaseOPeration getSTearDownOpeartion() throws Exception{
return DatabaseOperation.DELETE_ALL;
}
D. protected DatabaseOperation getSetUpOperation() throws Exception{
return DatabaseOperation.CLEAN_INSERT;
}
protected DatabaseOPeration getSTearDownOpeartion() throws Exception{
return DatabaseOperation.NONE;
}
39.Sam使用以下代码段创建了应用程序以检查输入的字符是原音还是辅音:
public class VowelConsonant{
public String check(String character){
String v = "vowel";
String c = "consonant";
if(character=="a"||character=="e"||character=="i"||character=="u"){
return v;
}else{
return c;
}
public static void main(String[] args){
//TODO code application logic here
}
}
}
现在他被分派的任务是通过创建三个测试用例来测试此应用程序,第一个用例检查元音,第二个用例检查辅音,第三个将不通过并显示相应的人类可阅读的错误消息。以下哪个选项将帮助他满足需求?
A. @Test
public void testCheck(){
System.out.println("Testing Vowel");
VowelConsonant vc = new VowelConsonant();
String result = vc.check("a");
assertThat(result,is(equalTo("vowel")));
}
@Test
public void testCheck2(){
System.out.println("Testing Vowel");
VowelConsonant vc = new VowelConsonant();
String result = vc.check("s");
assertThat(result,is(equalTo("consonant")));
}
@Test
public void testCheck3(){
System.out.println("Testing Vowel");
VowelConsonant vc = new VowelConsonant();
String result = vc.check("e");
assertThat(result,is(equalTo("consonant")));
}
B. @Test
public void testCheck(){
System.out.println("Testing Vowel");
VowelConsonant vc = new VowelConsonant();
String result = vc.check("a");
assertEquals(result,is(equalTo("vowel")));
}
@Test
public void testCheck2(){
System.out.println("Testing Vowel");
VowelConsonant vc = new VowelConsonant();
String result = vc.check("s");
assertEquals(result,is(equalTo("consonant")));
}
@Test
public void testCheck3(){
System.out.println("Testing Vowel");
VowelConsonant vc = new VowelConsonant();
String result = vc.check("e");
assertEquals(result,is(equalTo("consonant")));
}
C. @Test
public void testCheck(){
System.out.println("Testing Vowel");
VowelConsonant vc = new VowelConsonant();
String result = vc.check("a");
assertEquals(result,is(equalTo("vowel")));
}
@Test
public void testCheck2(){
System.out.println("Testing Vowel");
VowelConsonant vc = new VowelConsonant();
String result = vc.check("e");
assertEquals(result,is(equalTo("vowel")));
}
@Test
public void testCheck3(){
System.out.println("Testing Vowel");
VowelConsonant vc = new VowelConsonant();
String result = vc.check("o");
assertEquals(result,is(equalTo("vowel")));
}
D. @Test
public void testCheck(){
System.out.println("Testing Vowel");
VowelConsonant vc = new VowelConsonant();
String result = vc.check("a");
assertThat(result,is(equalTo("vowel")));
}
@Test
public void testCheck2(){
System.out.println("Testing Vowel");
VowelConsonant vc = new VowelConsonant();
String result = vc.check("e");
assertThat(result,is(equalTo("vowel")));
}
@Test
public void testCheck3(){
System.out.println("Testing Vowel");
VowelConsonant vc = new VowelConsonant();
String result = vc.check("o");
assertThat(result,is(equalTo("vowel")));
}
40.Roger开发了计算球体、立方体和圆锥体的体积的应用程序。他为其中每个操作创建了不同的Java类,例如Cone.java、Cube.java和Sphere.java.此外,他开发了不同的测试类以测试其中每个类,例如ConeTest.java、CubeTest.java和SphereTest.java。这些测试类是在volume包中定义的。现在他希望创建一个测试类并组合所有三个测试类以测试应用程序的整体功能。以下哪个选项将满足需求?
A. @RunWith({volume.SpereTest.class,volume.ConeTest.class,volume.CubeTest.class})
@Suite.SuiteClass(Suite.class)
public class TestSuite{
...........
}
B. @RunWith(Parameterized.class)
@Suite.SuiteClass({volume.SpereTest.class,volume.ConeTest.class,volume.CubeTest.class})
public class TestSuite{
...........
}
C. @RunWith(Suite.class)
@Suite.SuiteClass({volume.SpereTest.class,volume.CubeTest.class})
public class TestSuite{
...........
}
D. @RunWith(Suite.class)
@Suite.SuiteClass({volume.SpereTest.class,volume.ConeTest.class,volume.CubeTest.class})
public class TestSuite{
...........
}
-------------------------------------------------------------------------------------------------------------------------------------------------------
21.JUnit框架中的以下哪个元素是为了测试应用程序而执行的一个或多个测试用力或测试套件的集合?
A.测试用例 B.测试运行器 C.测试 D.测试结果
22.Mockito类的以下哪个方法用于指定要调用的模拟对象方法?
A.verify() B.when() C.thenReturn() D.andVoid()
23.以下哪个颜色表示最近工作版本的“未构建”状态?
A.红色 B.蓝色 C.灰色 D.黄色
24.您需要模拟那些类和接口来对Servlet进行单元测试?
A.HttpServletrequest,HttpServletResponse,HttpSession,ServletOutputStream
B.HttpServletResponse,HttpSession
C.HttpServletRequest,HttpSession
D.HttpSession,ServletOutputStream
25.以下哪个Hamcrest匹配器将在实际结果包含指定字符串的情况下匹配?
A.containsString
B.hasItem
C.allOf
D.closeTo
-------------------------------------------------------------------------------------------------------------------------------------------------------
-------------------------------------------------------------------------------------------------------------------------------------------------------



