题目详情

下图是银行卡应用的部分类图,图中属性和操作前的“+”和“-”分别表示公有成员和私有成员。银行卡Account有两种类型,借记卡SavingAccount和信用卡CreditAccount 。

中级软件评测师,章节练习,软件测试技术与应用

(1)借记卡和信用卡都有卡号account Number和余额balance两个属性。借记卡的余额是正常余额,信用卡的余额是目前未还的金额,如果没有未还的金额,则为0;有开户set Up、取款withdraw、查询余额get Balance和销户close四个方法。借记卡取钱时,要求取钱金额不能超过余额;而信用卡取钱金额不能超过信用额度,因此需要在子类中实现该方法。

(2)借记卡可以存钱deposit。

(3)信用卡有信用额度creditLimit属性,可以查询信用额度getCreditLimit、修改信用额度updateCreditLimit和还款retumCredit。现拟采用面向对象的方法进行测试。

问题:4.1

面向对象单元测试的主要对象是什么?

问题:4.2

在继承关系上,若某方法在测试父类时已经测试过,那么在什么情况下在子类中也需要测试?

问题:4.3

要测试方法deposit()时,还需要调用什么方法?给出测试序列。

问题:4.4

方法withdraw在基类Account中定义,但在两个子类中有不同的实现。这是面向对象的什么机制?这种情况在测试时如何进行?

问题:4.5

给出类SavingAccount的最小测试序列。

正确答案及解析

正确答案
解析

4.1

是针对程序的函数、过程或完成某以特定功能的程序块。

4.2

1、继承类的成员函数在子类中做了改动

2、成员函数调用了改动过的成员函数的部分

4.3

getBalance()

先测试getBalance()再测试deposit( )

4.4

多态。

只需要在原有的测试分析和基础上增加对测试用例中输入数据的类型的考虑;先测试基类,然后再分别依据输入数据设计不同的测试用例。

4.5

先测试Account类,然后测试SavingAccount类。

你可能感兴趣的试题

单选题

Advancements in ( )have contributed to the growth of the automotive industry through the creation and evolution of self-driving vehicles.

  • A.Artificial Intelligence
  • B.Cloud Computing
  • C.Internet of Things
  • D.Big Data
查看答案
单选题

In project human resource management , ( )is not a source of power for the project manager.

  • A.referent power
  • B.expert power
  • C.reward power
  • D.audit power
查看答案
单选题

At the project establishment stage , the feasibility study mainly includes techinical feasibility analysis , ( ), operation environment feasibility analysis and other aspects of feasibility analysis.

  • A.detail feasibility analysis
  • B.opportunity analysis
  • C.economic feasibility analysis
  • D.risk analysis
查看答案
单选题

( )is a grid that shows the project resources assigned to each work package.

  • A.Stakeholder engagement assessment matrix
  • B.Requirements traceability matrix
  • C.Probability and impact matrix
  • D.Responsibility assignment matrix
查看答案
单选题

Xinhua News Agency reported in January 2022,Chian will further promote the developmet of a digital economy during the 14th Five-Year Plan eriod(2021-2025). The plan also emphasized industrial ( )transformation.

  • A.digital
  • B.networking
  • C.intelligentize
  • D.informatization
查看答案

相关题库更多 +