JP6888336B2 - Stub generators, methods, and programs - Google Patents

Stub generators, methods, and programs Download PDF

Info

Publication number
JP6888336B2
JP6888336B2 JP2017044151A JP2017044151A JP6888336B2 JP 6888336 B2 JP6888336 B2 JP 6888336B2 JP 2017044151 A JP2017044151 A JP 2017044151A JP 2017044151 A JP2017044151 A JP 2017044151A JP 6888336 B2 JP6888336 B2 JP 6888336B2
Authority
JP
Japan
Prior art keywords
stub
class
type
generated
returned
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Active
Application number
JP2017044151A
Other languages
Japanese (ja)
Other versions
JP2018147388A (en
Inventor
スッパシット モンプラターンチャイ
スッパシット モンプラターンチャイ
竜一 梅川
竜一 梅川
忠弘 上原
忠弘 上原
裕介 佐々木
裕介 佐々木
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Fujitsu Ltd
Original Assignee
Fujitsu Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Fujitsu Ltd filed Critical Fujitsu Ltd
Priority to JP2017044151A priority Critical patent/JP6888336B2/en
Publication of JP2018147388A publication Critical patent/JP2018147388A/en
Application granted granted Critical
Publication of JP6888336B2 publication Critical patent/JP6888336B2/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Landscapes

  • Debugging And Monitoring (AREA)

Description

開示の技術は、スタブ生成装置、スタブ生成方法、及びスタブ生成プログラムに関する。 The disclosed technique relates to a stub generator, a stub generator, and a stub generator.

シンボリック実行によるプログラムのテスト技術において、テストケースの生成の際に、テスト環境の構築及び設定を行うドライバ、及びテスト対象のプログラムが呼び出すプログラム部品のダミー実装であるスタブを準備することが行われている。 In the program testing technology by symbolic execution, when a test case is generated, a driver that builds and sets the test environment and a stub that is a dummy implementation of the program parts called by the program to be tested are prepared. There is.

例えば、テスト対象となっているモジュールと、該モジュールから呼び出される依存モジュールと、該依存モジュールが行う手続きの振る舞いを代行するスタブとを、それぞれの記述内容に従って実行するモジュール実行手段を備えたシステムが提案されている。このモジュール実行手段は、テスト対象モジュールから依存モジュールへの呼び出しを検出し、呼び出しの処理を実行するモジュールとして依存モジュールかスタブかを所定の条件に従って決定し、決定に応じて当該呼び出しの処理を実行させる処理委譲手段を含む。 For example, a system equipped with a module execution means that executes a module to be tested, a dependent module called from the module, and a stub that substitutes for the behavior of the procedure performed by the dependent module according to the description contents of each. Proposed. This module execution means detects a call from the module under test to the dependent module, determines whether the module to execute the processing of the call is the dependent module or the stub according to a predetermined condition, and executes the processing of the call according to the determination. Includes processing delegation means to make.

また、対象プログラムと対象プログラム上のパスの情報とを入力し、対象プログラムから呼び出される外部プログラムによって更新される変数値のパス情報に即した変化を表したスタブプログラムを生成する情報処理装置が提案されている。この装置では、対象プログラムにおける外部プログラムへの呼出しをスタブプログラムへの呼出しに置換したテスト用対象プログラムを生成し、パス情報の初期値を用いてテスト用対象プログラムを呼び出すドライバプログラムを生成する。 In addition, an information processing device that inputs the target program and the path information on the target program and generates a stub program that represents the change according to the path information of the variable value updated by the external program called from the target program is proposed. Has been done. This device generates a test target program in which a call to an external program in the target program is replaced with a call to a stub program, and generates a driver program that calls the test target program using the initial value of the path information.

特開2009−129133号公報JP-A-2009-129133 特開2012−181666号公報Japanese Unexamined Patent Publication No. 2012-181666

対象プログラムに含まれるクラス間の継承関係が定義されている対象プログラムにおいて、ある変数にオブジェクトをアサインする際には、オブジェクトを適切なクラスに型変換する必要がある。 In the target program where the inheritance relationship between the classes included in the target program is defined, when assigning an object to a certain variable, it is necessary to type-convert the object to an appropriate class.

しかし、スタブから返却されるオブジェクトの型と、返却先のクラスの型との継承関係によっては、返却されたオブジェクトに対象プログラムがアクセスした際にエラーとなってしまう場合がある。この場合、対象プログラムのテストの実行がその時点で中断してしまい、テスト網羅性が低下してしまう。 However, depending on the inheritance relationship between the type of the object returned from the stub and the type of the return destination class, an error may occur when the target program accesses the returned object. In this case, the execution of the test of the target program is interrupted at that point, and the test coverage is lowered.

開示の技術は、一つの側面として、オブジェクトの型変換を含むテスト対象プログラムのシンボリック実行におけるテスト網羅性の低下を抑制するスタブを生成することを目的とする。 One aspect of the disclosed technique is to generate stubs that reduce test completeness in symbolic execution of the program under test, including type conversion of objects.

開示の技術は、一つの態様として、第1生成部が、テスト対象プログラムに含まれるメソッドから呼び出されるクラスをスタブ化し、ダミーのオブジェクトを返却する第1スタブを生成する。第2生成部が、前記第1生成部で生成された第1スタブから返却されるオブジェクトが、返却先で型変換される場合に、前記第1スタブに基づいて、前記オブジェクトの返却先での型変換が可能なオブジェクトを返却する第2スタブを生成する。更新部が、前記テスト対象プログラムにおいて、返却するオブジェクトが返却先で型変換されるクラスの呼び出しの対象を、前記第1スタブから、該第1スタブに基づいて生成された第2スタブに更新する。 In one aspect of the disclosed technique, the first generation unit stubs a class called from a method included in a program under test and generates a first stub that returns a dummy object. When the object returned from the first stub generated by the first generation unit is converted by the second generation unit at the return destination, the object is returned at the return destination based on the first stub. Generate a second stub that returns an object that can be type converted. In the test target program, the update unit updates the target of the class in which the returned object is type-converted at the return destination from the first stub to the second stub generated based on the first stub. ..

一つの側面として、オブジェクトの型変換を含むテスト対象プログラムのシンボリック実行におけるテスト網羅性の低下を抑制するスタブを生成することができる、という効果を有する。 One aspect is that it is possible to generate a stub that suppresses a decrease in test completeness in symbolic execution of a program under test including type conversion of an object.

本実施形態に係るスタブ生成装置の機能ブロック図である。It is a functional block diagram of the stub generator which concerns on this embodiment. シンボリック実行技術を用いたプログラムの単体テストの手順を説明するための図である。It is a figure for demonstrating the procedure of the unit test of a program using a symbolic execution technique. プリミティブタイプのメソッドの返却タイプ毎のデフォルト値の一例を示す図である。It is a figure which shows an example of the default value for each return type of a method of a primitive type. 返却タイプがプリミティブの場合のスタブ生成を説明するための図である。It is a figure for demonstrating the stub generation when the return type is a primitive. 返却タイプがユーザ指定タイプのオブジェクトの場合のスタブ生成を説明するための図である。It is a figure for demonstrating the stub generation when the return type is a user-specified type object. ダウンキャストによる例外発生を説明するための図である。It is a figure for demonstrating the exception occurrence by downcast. 本実施形態に係るスタブ生成装置として機能するコンピュータの概略を示すブロック図である。It is a block diagram which shows the outline of the computer which functions as the stub generation apparatus which concerns on this embodiment. 本実施形態におけるスタブ生成処理の一例を示すフローチャートである。It is a flowchart which shows an example of the stub generation processing in this embodiment. テスト対象クラスにおけるクラス間の継承関係を示す図である。It is a figure which shows the inheritance relationship between a class in a test subject class. テスト対象クラスの一例を示す図である。It is a figure which shows an example of the test subject class. オリジナルのスタブの生成を説明するための図である。It is a figure for demonstrating the generation of an original stub. クラスキャストを含むステートメントを説明するための図である。It is a figure for demonstrating the statement including a class cast. キャスト集合の一例を示す図である。It is a figure which shows an example of a cast set. 派生スタブの生成を説明するための図である。It is a figure for demonstrating the generation of a derivative stub. テスト対象クラスにおけるスタブクラス名の更新の一例を示す図である。It is a figure which shows an example of the update of the stub class name in the test subject class. テスト対象クラスからのスタブの呼び出しを示す図である。It is a figure which shows the call of a stub from a class under test. オリジナルのスタブを呼び出す場合を説明するための図である。It is a figure for demonstrating the case which calls the original stub. 派生スタブを呼び出す場合を説明するための図である。It is a figure for demonstrating the case which calls a derived stub.

以下、図面を参照して、開示の技術に関する実施形態の一例を詳細に説明する。なお、本実施形態では、テスト対象プログラムを、Java(登録商標)で記述されたクラス及びメソッドとする場合を例に説明する。 Hereinafter, an example of an embodiment relating to the disclosed technology will be described in detail with reference to the drawings. In this embodiment, a case where the program to be tested is a class and a method described in Java (registered trademark) will be described as an example.

図1に示すように、本実施形態に係るスタブ生成装置10は、テスト対象クラス31を入力として受け付ける。そして、スタブ生成装置10は、シンボリック実行技術を用いたプログラムの単体テストで用いるスタブを生成して出力する。 As shown in FIG. 1, the stub generator 10 according to the present embodiment accepts the test target class 31 as an input. Then, the stub generator 10 generates and outputs a stub to be used in the unit test of the program using the symbolic execution technique.

ここで、シンボリック実行技術を用いたプログラムの単体テストの手順について説明する。 Here, the procedure for unit testing a program using the symbolic execution technology will be described.

図2に示すように、まず、シンボリック実行ドライバ及びスタブを生成する(S100)。 As shown in FIG. 2, first, a symbolic execution driver and a stub are generated (S100).

なお、シンボリック実行ドライバとは、テスト対象クラス31の実行環境を構築及び設定し、テスト対象クラスを起動するプログラムである。また、スタブとは、テスト対象クラスが呼び出すプログラム部品のダミー実装である。テスト対象クラスから呼び出されるプログラム部品は、テスト対象クラスのテスト段階では、実装途中であったり、そのプログラム部品のテストが未実施であったりする場合がある。また、プログラム部品が、ファイルやデータベースなどへの外部アクセスを実行するものである場合もある。このような理由で、テスト時において、テスト対象クラスから呼び出されるプログラム部品を利用できない場合には、実際のプログラム部品の代わりにスタブを用いる。 The symbolic execution driver is a program that builds and sets the execution environment of the test target class 31 and starts the test target class. The stub is a dummy implementation of the program component called by the test target class. The program component called from the test target class may be in the process of being implemented or the program component may not be tested at the test stage of the test target class. In addition, a program component may execute external access to a file, a database, or the like. For this reason, if the program component called from the test target class cannot be used at the time of testing, a stub is used instead of the actual program component.

次に、生成したシンボリック実行ドライバ及びスタブと、テスト対象クラスとをシンボリック実行エンジン200に入力し、シンボリック実行エンジン200でテストケースが生成される(S101)。そして、生成されたテストケースを使って、単体テストツール201によりテストを実行することにより、テスト対象クラスについてのテスト結果が得られる(S103)。 Next, the generated symbolic execution driver and stub and the test target class are input to the symbolic execution engine 200, and a test case is generated by the symbolic execution engine 200 (S101). Then, by executing the test with the unit test tool 201 using the generated test case, the test result for the test target class can be obtained (S103).

スタブの生成について、テスト対象クラスに含まれるメソッドから呼び出されるクラスであって、スタブ化対象のクラスからの各メソッドへの返却値のタイプ(以下、「返却タイプ」という)がプリミティブタイプの場合を考える。この場合、実装ボディなしで、例えば図3に示すように、メソッドの返却タイプに応じて予め定められたデフォルト値を返却するようなスタブが生成される。例えば、図4に示すように、オリジナルのクラス(StubSample)を呼び出すmethod1の返却タイプは「int」であり、プリミティブタイプである。図3の例を用いると、返却タイプ「int」に対するデフォルト値は「0」であるため、method1のボディ部分に、0を返却するコード(「return 0」)を記述する。また、オリジナルのクラス(StubSample)に含まれるmethod2のように、返却タイプが「void」の場合、スタブからは何も返却しないため、ボディ部分は空のままとする。このように、オリジナルのクラスがスタブ化される。すなわち、スタブが生成される。 Regarding the generation of stub, when the class is called from the method included in the test target class and the type of return value from the stub target class to each method (hereinafter referred to as "return type") is a primitive type. Think. In this case, without the implementation body, for example, as shown in FIG. 3, a stub that returns a predetermined default value according to the return type of the method is generated. For example, as shown in FIG. 4, the return type of method1 that calls the original class (StubSample) is "int", which is a primitive type. Using the example of FIG. 3, since the default value for the return type "int" is "0", a code for returning 0 ("return 0") is described in the body part of method1. Also, when the return type is "void" like method2 included in the original class (StubSimple), nothing is returned from the stub, so the body part is left empty. In this way, the original class is stubbed. That is, a stub is generated.

また、スタブの生成について、スタブ化対象のクラスを呼び出すメソッドの返却タイプがユーザ指定タイプの場合を考える。例えば、スタブ化対象のクラスを呼び出すmethod1の返却タイプ「ClassA」が、図5に示すようなユーザ指定タイプであるとする。この場合、スタブから「null」を返却した場合、テスト対象クラスにおいて、その返却値「Null」にアクセスする箇所で、NullPointerException例外が発生してしまう。この例外発生を避けるために、ユーザ指定タイプのオブジェクトのインスタンスを返却するスタブが生成される。コンストラクタの各引数にはデフォルト値が渡される。 Also, regarding the generation of stubs, consider the case where the return type of the method that calls the class to be stubized is the user-specified type. For example, it is assumed that the return type "ClassA" of method1 that calls the class to be stubbed is a user-specified type as shown in FIG. In this case, when "null" is returned from the stub, a NullPointerException exception occurs at the point where the return value "Null" is accessed in the test target class. To avoid this exception, a stub is generated that returns an instance of a user-specified type of object. Default values are passed to each argument of the constructor.

ここで、テスト対象クラスに含まれるメソッドから呼び出される各クラス間に継承関係が定義されている場合、ある変数にオブジェクトをアサインする際には、適切なクラスにキャスト(型変換)する必要がある。Java(登録商標)の場合、子クラスから親クラスへのキャスト(アップキャスト)は可能であるが、親クラスから子クラスへのキャスト(ダウンキャスト)は不可である。ただし、アップキャスト後のダウンキャストは可能である。 Here, if an inheritance relationship is defined between each class called from the method included in the test target class, when assigning an object to a certain variable, it is necessary to cast (type conversion) to the appropriate class. .. In the case of Java (registered trademark), casting from child class to parent class (upcast) is possible, but casting from parent class to child class (downcast) is not possible. However, downcasting after upcasting is possible.

例えば、子クラス「Child」が親クラス「Parent」を継承する場合のクラスキャストには、以下のパターンがある。 For example, there are the following patterns in the class cast when the child class "Child" inherits the parent class "Parent".

(1) Parent p = (Parent) new Child();
(2) Parent p = (Parent) new Child();
Child c = (Child) p;
(3) Child c = (Child) new Parent();
(1) Partent p = (Parent) newChild ();
(2) Partent p = (Parent) newChild ();
Child c = (Child) p;
(3) Child c = (Child) new Partent ();

上記(1)の「new Child()」は、子クラス「Child」のオブジェクトをインスタンス化することを表し、「(Parent)」は、オブジェクトを親クラス「Parent」にキャストすることを表す。また、「Parent p =」は、親クラス「Parent」の変数pにオブジェクトをアサインすることを表す。すなわち、上記(1)はアップキャストを表しており、このようなクラスキャストは可能である。 The "new Child ()" in (1) above represents instantiation of an object of the child class "Child", and "(Parent)" represents casting the object to the parent class "Parent". Further, "Parent p =" indicates that an object is assigned to the variable p of the parent class "Parent". That is, the above (1) represents an upcast, and such a classcast is possible.

上記(2)は、インスタンス化した子クラス「Child」のオブジェクトを親クラス「Parent」へキャストし、キャストしたオブジェクトを子クラス「Child」にキャストしている。すなわち、上記(2)はアップキャスト後のダウンキャストを表しており、このようなクラスキャストは可能である。 In (2) above, the instantiated child class "Child" object is cast to the parent class "Parent", and the cast object is cast to the child class "Child". That is, the above (2) represents a downcast after an upcast, and such a classcast is possible.

上記(3)は、インスタンス化した親クラス「Parent」のオブジェクトを子クラス「Child」へダウンキャストすることを表しており、このようなクラスキャストは不可である。 The above (3) represents downcasting the object of the instantiated parent class "Parent" to the child class "Child", and such a class cast is not possible.

次に、テスト対象クラスにおいて、スタブから返却されるオブジェクトがクラスキャストされる場合に生じる問題点について説明する。 Next, in the test target class, the problem that occurs when the object returned from the stub is class cast will be described.

図6に示すように、テスト対象クラスから呼び出されるオリジナルのクラスからは、子クラス「Child」から親クラス「Parent」にアップキャストされたオブジェクトpが返却される。返却先では、親クラス「Parent」のオブジェクトpが子クラス「Child」にキャストされる。この場合、アップキャスト後のダウンキャストであるため、クラスキャストが可能である。 As shown in FIG. 6, the object p upcast from the child class "Child" to the parent class "Parent" is returned from the original class called from the test target class. At the return destination, the object p of the parent class "Parent" is cast to the child class "Child". In this case, since it is a downcast after an upcast, a class cast is possible.

しかし、このオリジナルのクラスをスタブ化する際に、図6に示すように、method1の返却タイプ「Parent」のインスタンスを返却するスタブが生成されるとする。この場合、オブジェクトの返却先では、親クラス「Parent」から子クラス「Child」へのダウンキャストとなるため、ClassCastException例外が発生してしまう。 However, when this original class is stubized, as shown in FIG. 6, it is assumed that a stub for returning an instance of the return type "Parent" of method1 is generated. In this case, the return destination of the object is a downcast from the parent class "Parent" to the child class "Child", so a ClassCastException exception occurs.

そこで、本実施形態では、オブジェクトの返却先でのクラスキャストに応じたオブジェクトを返却するスタブを生成する。以下、スタブ生成装置10の各部について詳述する。 Therefore, in the present embodiment, a stub that returns the object according to the class cast at the object return destination is generated. Hereinafter, each part of the stub generator 10 will be described in detail.

図1に示すように、スタブ生成装置10は、機能的には、スタブ生成部11と、解析部12と、派生スタブ生成部13と、更新部14とを含む。なお、スタブ生成部11は、開示の技術の第1生成部の一例であり、解析部12及び派生スタブ生成部13は、開示の技術の第2生成部の一例である。 As shown in FIG. 1, the stub generation device 10 functionally includes a stub generation unit 11, an analysis unit 12, a derivative stub generation unit 13, and an update unit 14. The stub generation unit 11 is an example of the first generation unit of the disclosed technology, and the analysis unit 12 and the derivative stub generation unit 13 are examples of the second generation unit of the disclosure technology.

スタブ生成部11は、入力されたテスト対象クラスに含まれるメソッドから呼び出されるスタブ化対象クラスをスタブ化し、シンボリック実行時に呼び出されるスタブを生成する。スタブ生成部11によるスタブの生成方法は、従来既知の手法を用いることができるため、本実施形態では詳細な説明を省略する。 The stub generation unit 11 stubs the stubization target class called from the method included in the input test target class, and generates a stub to be called at the time of symbolic execution. As a method for generating stubs by the stub generation unit 11, a conventionally known method can be used, and therefore detailed description thereof will be omitted in the present embodiment.

解析部12は、スタブ生成部11で生成されたスタブから返却されるオブジェクトが、テスト対象クラスの返却先においてクラスキャストされる箇所を特定する。 The analysis unit 12 identifies a place where the object returned from the stub generated by the stub generation unit 11 is class cast at the return destination of the test target class.

具体的には、解析部12は、スタブ生成部11で生成されたスタブ(スタブ化されたクラス)のクラス名(以下、「スタブクラス名」という)を収集し、スタブ集合21に格納する。また、解析部12は、テスト対象クラスから、スタブ集合21に格納されたスタブクラス名が示すスタブを呼び出し、かつそのスタブから返却されるオブジェクトがキャストされるステートメントを全て抽出する。解析部12は、抽出した各ステートメントから、オブジェクトのキャスト先のクラス、呼び出されるスタブのスタブクラス名、及びそのスタブを呼び出すメソッドのメソッド名の情報を取得する。解析部12は、取得した情報からレコードを作成してキャスト集合22に格納する。 Specifically, the analysis unit 12 collects the class names (hereinafter, referred to as “stub class names”) of the stubs (stubized classes) generated by the stub generation unit 11 and stores them in the stub set 21. Further, the analysis unit 12 calls the stub indicated by the stub class name stored in the stub set 21 from the test target class, and extracts all statements in which the object returned from the stub is cast. From each extracted statement, the analysis unit 12 acquires information on the class to which the object is cast, the stub class name of the stub to be called, and the method name of the method that calls the stub. The analysis unit 12 creates a record from the acquired information and stores it in the cast set 22.

派生スタブ生成部13は、返却先でクラスキャストされるオブジェクトを返却するスタブから、キャスト先のクラスに応じたオブジェクトを返却するスタブを派生させて生成する。以下、派生スタブ生成部13で生成するスタブを「派生スタブ」という。 The derived stub generation unit 13 generates a stub that returns an object corresponding to the cast destination class by deriving a stub that returns an object that is class cast at the return destination. Hereinafter, the stub generated by the derived stub generation unit 13 is referred to as a “derivative stub”.

具体的には、派生スタブ生成部13は、キャスト集合22に格納された各レコードに含まれるスタブクラス名が示すスタブのコードを複製して、スタブクラス名を派生スタブであることを表す名前に変更する。例えば、派生スタブ生成部13は、派生スタブのスタブクラス名を、元のスタブのスタブクラス名の後に「派生i」を付加した名前に変更することができる。iは、派生スタブを生成する毎に、0からカウントアップされる整数とすることができる。また、派生スタブ生成部13は、生成した派生スタブのスタブクラス名を、キャスト集合22における該当のレコードに追加する。 Specifically, the derived stub generator 13 duplicates the stub code indicated by the stub class name included in each record stored in the cast set 22, and changes the stub class name to a name indicating that it is a derived stub. change. For example, the derived stub generation unit 13 can change the stub class name of the derived stub to a name obtained by adding "derivative i" after the stub class name of the original stub. i can be an integer that counts up from 0 each time a derived stub is created. Further, the derived stub generation unit 13 adds the stub class name of the generated derived stub to the corresponding record in the cast set 22.

また、派生スタブ生成部13は、キャスト先のクラスに応じたオブジェクトをインスタンス化して返却するように、派生スタブ内の呼出先メソッドのボディ部におけるreturnの記述を修正する。 Further, the derived stub generation unit 13 modifies the description of return in the body part of the called method in the derived stub so that the object corresponding to the cast destination class is instantiated and returned.

更新部14は、テスト対象クラスにおいて、キャスト集合22に格納された各レコードの情報に相当するステートメントを検出する。更新部14は、検出したステートメントにおいて呼び出すスタブのスタブクラス名を、該当のレコードに含まれる派生スタブのスタブクラス名に更新する。 The update unit 14 detects a statement corresponding to the information of each record stored in the cast set 22 in the test target class. The update unit 14 updates the stub class name of the stub to be called in the detected statement to the stub class name of the derived stub included in the corresponding record.

スタブ生成装置10は、例えば、図7に示すコンピュータ60で実現することができる。コンピュータ60はCentral Processing Unit(CPU)61、一時記憶領域としてのメモリ62、及び不揮発性の記憶部63を備える。また、コンピュータ60は、表示装置及び入力装置等の入出力装置64、記憶媒体69に対するデータの読み込みと書き込みとを制御するread/write(R/W)部65、及びインターネット等のネットワークに接続されるネットワークinterface(I/F)66を備える。CPU61、メモリ62、記憶部63、入出力装置64、R/W部65、及びネットワークI/F66は、バス67を介して互いに接続される。 The stub generator 10 can be realized by, for example, the computer 60 shown in FIG. The computer 60 includes a Central Processing Unit (CPU) 61, a memory 62 as a temporary storage area, and a non-volatile storage unit 63. Further, the computer 60 is connected to an input / output device 64 such as a display device and an input device, a read / write (R / W) unit 65 that controls reading and writing of data to a storage medium 69, and a network such as the Internet. The network interface (I / F) 66 is provided. The CPU 61, the memory 62, the storage unit 63, the input / output device 64, the R / W unit 65, and the network I / F 66 are connected to each other via the bus 67.

記憶部63は、Hard Disk Drive(HDD)、solid state drive(SSD)、フラッシュメモリ等によって実現できる。記憶媒体としての記憶部63には、コンピュータ60をスタブ生成装置10として機能させるためのスタブ生成プログラム70が記憶される。 The storage unit 63 can be realized by a Hard Disk Drive (HDD), a solid state drive (SSD), a flash memory, or the like. The storage unit 63 as a storage medium stores a stub generation program 70 for causing the computer 60 to function as the stub generation device 10.

CPU61は、スタブ生成プログラム70を記憶部63から読み出してメモリ62に展開し、スタブ生成プログラム70が有するプロセスを順次実行する。スタブ生成プログラム70は、スタブ生成プロセス71と、解析プロセス72と、派生スタブ生成プロセス73と、更新プロセス74とを有する。CPU61は、スタブ生成プロセス71を実行することで、図1に示すスタブ生成部11として動作する。また、CPU61は、解析プロセス72を実行することで、図1に示す解析部12として動作する。また、CPU61は、派生スタブ生成プロセス73を実行することで、図1に示す派生スタブ生成部13として動作する。また、CPU61は、更新プロセス74を実行することで、図1に示す更新部14として動作する。これにより、スタブ生成プログラム70を実行したコンピュータ60が、スタブ生成装置10として機能することになる。 The CPU 61 reads the stub generation program 70 from the storage unit 63, expands the stub generation program 70 into the memory 62, and sequentially executes the processes included in the stub generation program 70. The stub generation program 70 includes a stub generation process 71, an analysis process 72, a derived stub generation process 73, and an update process 74. The CPU 61 operates as the stub generation unit 11 shown in FIG. 1 by executing the stub generation process 71. Further, the CPU 61 operates as the analysis unit 12 shown in FIG. 1 by executing the analysis process 72. Further, the CPU 61 operates as the derived stub generation unit 13 shown in FIG. 1 by executing the derived stub generation process 73. Further, the CPU 61 operates as the update unit 14 shown in FIG. 1 by executing the update process 74. As a result, the computer 60 that has executed the stub generation program 70 functions as the stub generation device 10.

なお、スタブ生成プログラム70により実現される機能は、例えば半導体集積回路、より詳しくはApplication Specific Integrated Circuit(ASIC)等で実現することも可能である。 The function realized by the stub generation program 70 can also be realized by, for example, a semiconductor integrated circuit, more specifically, an Application Specific Integrated Circuit (ASIC) or the like.

次に、本実施形態に係るスタブ生成装置10の作用について説明する。スタブ生成装置10にテスト対象クラスが入力されると、スタブ生成装置10において、図8に示すスタブ生成処理が実行される。なお、ここでは、図9に示すようなクラス間の継承関係が定義されたテスト対象クラスが入力されるものとする。図9は、親クラス「果物」を継承する子クラス「みかん」及び「バナナ」と、親クラス「動物」を継承する子クラス「猫」及び「犬」とが定義されている例を示している。また、図10に示すように、テスト対象クラス31のメソッドから呼び出されるユーザ定義クラスとして、クラス41A(クラス名「スタブA」)及びクラス41B(クラス名「スタブB」)が定義されている。以下では、このオリジナルのクラス41A及び41Bをスタブ化対象クラスとする場合について説明する。 Next, the operation of the stub generator 10 according to the present embodiment will be described. When the test target class is input to the stub generation device 10, the stub generation device 10 executes the stub generation process shown in FIG. Here, it is assumed that the test target class in which the inheritance relationship between the classes as shown in FIG. 9 is defined is input. FIG. 9 shows an example in which the child classes “orange” and “banana” inheriting the parent class “fruit” and the child classes “cat” and “dog” inheriting the parent class “animal” are defined. There is. Further, as shown in FIG. 10, class 41A (class name "stub A") and class 41B (class name "stub B") are defined as user-defined classes called from the method of the test target class 31. In the following, a case where the original classes 41A and 41B are set as stub target classes will be described.

図8に示すスタブ生成処理のステップS11で、スタブ生成部11が、スタブ化対象のオリジナルのクラス41A及び41Bをスタブ化し、スタブ42A(スタブクラス名「スタブA」)及びスタブ42B(スタブクラス名「スタブB」)を生成する。ここでは、図11に示すように、オリジナルのクラスを呼び出すメソッドの返却タイプのオブジェクトのインスタンスを返却するスタブ42A及び42Bが生成される。 In step S11 of the stub generation process shown in FIG. 8, the stub generation unit 11 stubs the original classes 41A and 41B to be stubized, and stubs 42A (stub class name “stub A”) and stub 42B (stub class name). "Stub B") is generated. Here, as shown in FIG. 11, stubs 42A and 42B that return an instance of the return type object of the method that calls the original class are generated.

次に、ステップS12で、解析部12が、スタブ生成部11により生成されたスタブのスタブクラス名をスタブ集合21に格納する。ここでは、スタブクラス名「スタブA」及び「スタブB」がスタブ集合21に格納される。 Next, in step S12, the analysis unit 12 stores the stub class name of the stub generated by the stub generation unit 11 in the stub set 21. Here, the stub class names "stub A" and "stub B" are stored in the stub set 21.

次に、ステップS13で、解析部12が、テスト対象クラス31から、スタブ集合21に格納されたスタブクラス名が示すスタブを呼び出し、かつそのスタブから返却されるオブジェクトがキャストされるステートメントを全て抽出する。解析部12は、例えば、キャストを示す記述(本実施形態では、「(みかん)」のように、( )内にキャスト先のクラスを表記した記述)を含むステートメントを抽出することができる。 Next, in step S13, the analysis unit 12 calls the stub indicated by the stub class name stored in the stub set 21 from the test target class 31, and extracts all statements in which the object returned from the stub is cast. To do. The analysis unit 12 can extract, for example, a statement including a description indicating the cast (in the present embodiment, a description in which the cast destination class is described in (), such as “(mandarin orange)”).

次に、ステップS14で、解析部12が、抽出した各ステートメントから、オブジェクトのキャスト先のクラス、呼び出されるスタブのスタブクラス名、及びそのスタブを呼び出すメソッドのメソッド名の情報を取得する。例えば、図12に示すように、本実施形態では、解析部12は、ステートメント中の( )内からキャスト先のクラスを取得し、それに続く記述の「.(ドット)」の前部分をスタブクラス名、後部分をメソッド名として取得することができる。 Next, in step S14, the analysis unit 12 acquires information on the class to which the object is cast, the stub class name of the stub to be called, and the method name of the method that calls the stub from each of the extracted statements. For example, as shown in FIG. 12, in the present embodiment, the analysis unit 12 acquires the cast destination class from the inside of () in the statement, and the part before the “. (Dot)” in the subsequent description is the stub class. You can get the name and the latter part as the method name.

解析部12は、取得した情報からレコードを作成してキャスト集合22に格納する。図13に、テスト対象クラス31の各ステートメントからキャスト集合22に格納されるレコードの例を示す。なお、テスト対象クラス31の3行目のステートメント(図13中の破線部)は、キャストを示す記述が含まれないため、上記ステップS13で抽出されない。 The analysis unit 12 creates a record from the acquired information and stores it in the cast set 22. FIG. 13 shows an example of records stored in the cast set 22 from each statement of the test target class 31. The statement on the third line of the test target class 31 (broken line portion in FIG. 13) is not extracted in step S13 because it does not include a description indicating the cast.

次に、ステップS15で、派生スタブ生成部13が、キャスト集合22に格納されたレコードを特定するための変数iを初期値の0に設定する。 Next, in step S15, the derived stub generation unit 13 sets the variable i for specifying the record stored in the cast set 22 to the initial value 0.

次に、ステップS16で、派生スタブ生成部13が、変数iがキャスト集合22に格納されたレコード数より小さいか否かを判定する。i<キャスト集合のレコード数の場合には、処理はステップS17へ移行する。 Next, in step S16, the derived stub generation unit 13 determines whether or not the variable i is smaller than the number of records stored in the cast set 22. If i <the number of records in the cast set, the process proceeds to step S17.

ステップS17では、派生スタブ生成部13が、キャスト集合22に格納されたi−1番目のレコードを、以下のステップS18〜S21の処理対象のレコードに設定する。 In step S17, the derived stub generation unit 13 sets the i-1st record stored in the cast set 22 to the records to be processed in the following steps S18 to S21.

次に、ステップS18で、派生スタブ生成部13が、処理対象のレコードに含まれるスタブクラス名が示すスタブのコードを複製して、派生スタブを生成する。図14に示すように処理対象のレコード51(図13に示すキャスト集合22の1行目のレコード)が設定されている場合、レコード51の「スタブクラス名」からスタブ42A(スタブクラス名「スタブA」)が特定される。そして、このスタブ42Aが複製されて、派生スタブ43Aが生成される。 Next, in step S18, the derived stub generation unit 13 duplicates the stub code indicated by the stub class name included in the record to be processed to generate the derived stub. When the record 51 to be processed (the record in the first row of the cast set 22 shown in FIG. 13) is set as shown in FIG. 14, the stub 42A (stub class name “stub”” from the “stub class name” of the record 51 is set. A ") is specified. Then, this stub 42A is duplicated to generate a derivative stub 43A.

次に、ステップS19で、派生スタブ生成部13が、図14の破線部Pに示すように、元のスタブクラスのクラス名(「スタブA」)の後に「派生i」を付加する。 Next, in step S19, the derived stub generation unit 13 adds “derivative i” after the class name (“stub A”) of the original stub class, as shown by the broken line portion P in FIG.

次に、ステップS20で、派生スタブ生成部13が、キャスト先のクラスに応じたオブジェクトをインスタンス化して返却するように、派生スタブ内の呼出先メソッドのボディ部におけるreturnの記述を修正する。図14の破線部Qは、キャスト先のクラスである子クラス「みかん」のオブジェクトをインスタンス化して、親クラス「果物」にアップキャストしたオブジェクトを返却するように修正した例である。この場合、返却先ではアップキャスト後のダウンキャストとなり、クラスキャストが適切に行われる。 Next, in step S20, the description of return in the body part of the called method in the derived stub is modified so that the derived stub generation unit 13 instantiates and returns the object corresponding to the cast destination class. The broken line part Q in FIG. 14 is an example in which the object of the child class “Mikan”, which is the cast destination class, is instantiated and the object upcast to the parent class “Fruit” is returned. In this case, the return destination will be the downcast after the upcast, and the class cast will be performed appropriately.

次に、ステップS21で、派生スタブ生成部13が、図14の矢印Rに示すように、生成した派生スタブのスタブクラス名を、キャスト集合22における処理対象のレコードに追加する。 Next, in step S21, the derived stub generation unit 13 adds the generated stub class name of the derived stub to the record to be processed in the cast set 22 as shown by the arrow R in FIG.

次に、ステップS22で、派生スタブ生成部13が、変数iを1インクリメントして、処理はステップS16に戻る。本実施形態では、ステップS16〜S22の繰り返し処理により、図13に示すキャスト集合22の2行目のレコードからスタブA派生1、3行目のレコードからスタブA派生2、4行目のレコードからスタブB派生3が生成される。ステップS16で、iがキャスト集合22のレコード数を超えたと判定されると、処理はステップS23へ移行する。 Next, in step S22, the derivative stub generation unit 13 increments the variable i by 1, and the process returns to step S16. In the present embodiment, by the iterative processing of steps S16 to S22, the stub A derivative 1 is derived from the record in the second row of the cast set 22 shown in FIG. The stub B derivative 3 is generated. If it is determined in step S16 that i exceeds the number of records in the cast set 22, the process proceeds to step S23.

ステップS23では、更新部14が、テスト対象クラス31において、キャスト集合22に格納された各レコードの情報に相当するステートメントを検出する。そして、更新部14は、図15に示すように、検出したステートメントにおいて呼び出すスタブのスタブクラス名を、該当のレコードに含まれる派生スタブのスタブクラス名に更新する。図15の4〜7行目のステートメントでは、呼び出すスタブが派生スタブ生成部13により生成された派生スタブに更新されている。また、3行目のステートメントでは、返却オブジェクトはキャストされないため、呼び出すスタブはスタブ生成部11により生成されたオリジナルのスタブのままである。 In step S23, the update unit 14 detects a statement corresponding to the information of each record stored in the cast set 22 in the test target class 31. Then, as shown in FIG. 15, the update unit 14 updates the stub class name of the stub to be called in the detected statement to the stub class name of the derived stub included in the corresponding record. In the statements on lines 4 to 7 of FIG. 15, the stub to be called is updated to the derived stub generated by the derived stub generator 13. Also, in the statement on the third line, the returned object is not cast, so the stub to be called remains the original stub generated by the stub generator 11.

更新部14によるスタブクラス名の更新が終了すると、スタブ生成部11により生成されたスタブ、及び派生スタブ生成部13により生成された派生スタブが出力され、スタブ生成処理は終了する。 When the update of the stub class name by the update unit 14 is completed, the stub generated by the stub generation unit 11 and the derived stub generated by the derivative stub generation unit 13 are output, and the stub generation process ends.

図16に、テスト対象クラス31からのスタブの呼び出しを概略的に示す。テスト対象クラス31の4行目のステートメントからは、派生スタブ43A0(スタブクラス名「スタブA派生0」)が呼び出される。また、5行目のステートメントからは、派生スタブ43A1(スタブクラス名「スタブA派生1」)が呼び出される。また、6行目のステートメントからは、派生スタブ43A2(スタブクラス名「スタブA派生2」)が呼び出される。また、5行目のステートメントからは、派生スタブ43B(スタブクラス名「スタブB派生3」)が呼び出される。なお、3行目のステートメントからは、オリジナルのスタブ42A(スタブクラス名「スタブA」)が呼び出される。 FIG. 16 schematically shows a stub call from the test target class 31. Derived stub 43A0 (stub class name "stub A derived 0") is called from the statement on the fourth line of the test target class 31. Further, the derived stub 43A1 (stub class name "stub A derivative 1") is called from the statement on the fifth line. In addition, the derived stub 43A2 (stub class name "stub A derivative 2") is called from the statement on the sixth line. Further, the derived stub 43B (stub class name "stub B derivative 3") is called from the statement on the fifth line. The original stub 42A (stub class name "stub A") is called from the statement on the third line.

以上説明したように、本実施形態に係るスタブ生成装置は、テスト対象クラスのメソッドから呼び出されるクラスのダミーであるスタブを生成する。このスタブをそのまま使用した場合、図17に示すように、スタブから返却されるオブジェクトが返却先でダウンキャストとなり、例外が発生する場合がある。そこで、本実施形態では、図18に示すように、オリジナルのスタブから、キャスト先のクラスに応じたオブジェクトを返却するような派生スタブを生成する。そして、テスト対象クラスにおいて、呼び出すスタブを派生スタブに更新する。これにより、ダウンキャストの発生を抑止することができる。なお、キャストがないステートメントからのクラスの呼び出しの場合には、オリジナルのスタブを呼び出す。 As described above, the stub generator according to the present embodiment generates a stub that is a dummy of the class called from the method of the test target class. If this stub is used as it is, as shown in FIG. 17, the object returned from the stub may be downcast at the return destination, and an exception may occur. Therefore, in the present embodiment, as shown in FIG. 18, a derived stub that returns an object according to the cast destination class is generated from the original stub. Then, in the test target class, the stub to be called is updated to the derived stub. As a result, the occurrence of downcast can be suppressed. If the class is called from a statement without a cast, the original stub is called.

これにより、クラスキャストのエラーによりテスト対象クラスのシンボリック実行が中断されることを防止できるため、テスト網羅性の低下を抑制することができる。 As a result, it is possible to prevent the symbolic execution of the test target class from being interrupted due to a class cast error, and thus it is possible to suppress a decrease in test completeness.

なお、上述したように、エラーが発生するのはダウンキャストの場合である。そのため、上記実施形態では、クラスキャストとしてダウンキャストのみを扱う場合について説明したが、アップキャストが混在するテスト対象クラスに対しても開示の技術を適用することができる。この場合、ダウンキャストとアップキャストとを区別することなく、返却オブジェクトがキャストされる場合に、派生スタブを生成すればよい。アップキャストの場合、派生スタブから返却されるオブジェクトのクラスは、オリジナルのスタブから返却されるオブジェクトのクラスと同じになるため、問題は生じない。なお、図9に示すようなクラスの継承関係を参照して、ダウンキャストの場合のみ派生スタブを生成するようにしてもよい。この場合、不要な派生スタブの生成を抑制することができる。 As described above, the error occurs in the case of downcast. Therefore, in the above embodiment, the case where only the downcast is handled as the classcast has been described, but the disclosed technique can be applied to the test target class in which the upcast is mixed. In this case, the derived stub may be generated when the returned object is cast without distinguishing between the downcast and the upcast. In the case of upcast, the class of the object returned from the derived stub is the same as the class of the object returned from the original stub, so there is no problem. It should be noted that the derived stub may be generated only in the case of downcast by referring to the inheritance relationship of the class as shown in FIG. In this case, it is possible to suppress the generation of unnecessary derivative stubs.

また、上記実施形態では、Java(登録商標)で記述されたクラス及びメソッドを、テスト対象のプログラムとする場合について説明したが、これに限定されない。開示の技術は、他の言語で記述されたプログラム、特に、オブジェクト指向言語で記述されたプログラムに適用可能である。 Further, in the above embodiment, the case where the class and method described in Java (registered trademark) is used as the program to be tested has been described, but the present invention is not limited to this. The disclosed technique is applicable to programs written in other languages, especially programs written in object-oriented languages.

また、上記では、スタブ生成プログラム70が記憶部63に予め記憶(インストール)されている態様を説明したが、これに限定されない。開示の技術に係るプログラムは、CD−ROM、DVD−ROM、USBメモリ等の記憶媒体に記録された形態で提供することも可能である。 Further, in the above description, the mode in which the stub generation program 70 is stored (installed) in the storage unit 63 in advance has been described, but the present invention is not limited to this. The program according to the disclosed technology can also be provided in a form recorded on a storage medium such as a CD-ROM, a DVD-ROM, or a USB memory.

以上の実施形態に関し、更に以下の付記を開示する。 Regarding the above embodiments, the following additional notes will be further disclosed.

(付記1)
テスト対象プログラムからのクラスの呼び出しに対して、ダミーのオブジェクトを返却する第1スタブを生成する第1生成部と、
前記第1生成部で生成された第1スタブから返却されるオブジェクトが、返却先で型変換される場合に、前記第1スタブに基づいて、前記オブジェクトの返却先での型変換に対応したオブジェクトを返却する第2スタブを生成する第2生成部と、
前記テスト対象プログラムにおいて、型変換を伴うクラスの呼び出しの対象を、前記第1スタブから、該第1スタブに基づいて生成された第2スタブに更新する更新部と、
を含むスタブ生成装置。
(Appendix 1)
A first generator that creates a first stub that returns a dummy object in response to a class call from the program under test,
When the object returned from the first stub generated by the first generation unit is type-converted at the return destination, the object corresponding to the type conversion at the return destination of the object based on the first stub. A second generator that generates a second stub that returns
In the test target program, an update unit that updates the target of a class call involving type conversion from the first stub to a second stub generated based on the first stub.
Stub generator including.

(付記2)
前記第1生成部は、前記クラスの型に応じたオブジェクトを返却する第1スタブを生成し、
前記第2生成部は、前記第1スタブにおいて、前記クラスの型に応じたオブジェクトを返却することを示す記述を、返却先の型変換時にエラーが発生しない型のオブジェクトを返却することを示す記述に書き換えることにより第2スタブを生成する
付記1に記載のスタブ生成装置。
(Appendix 2)
The first generation unit generates a first stub that returns an object according to the type of the class.
In the first stub, the second generation unit includes a description indicating that an object corresponding to the type of the class is returned, and a description indicating that an object of a type that does not cause an error during type conversion of the return destination is returned. The stub generator according to Appendix 1, which generates a second stub by rewriting to.

(付記3)
前記第2生成部は、前記テスト対象プログラムから、型変換を伴うクラスの呼び出しを示す記述を抽出し、抽出した記述に含まれるクラスの呼び出しに対して前記第1生成部で生成された前記第1スタブを複製し、複製した第1スタブにおけるオブジェクトの返却に関する記述を書き換えることにより、前記第2スタブを生成する付記2に記載のスタブ生成装置。
(Appendix 3)
The second generation unit extracts a description indicating a class call accompanied by type conversion from the test target program, and the first generation unit is generated for the class call included in the extracted description. The stub generation device according to Appendix 2, which generates the second stub by duplicating one stub and rewriting the description regarding the return of an object in the duplicated first stub.

(付記4)
テスト対象プログラムからのクラスの呼び出しに対して、ダミーのオブジェクトを返却する第1スタブを生成し、
生成された第1スタブから返却されるオブジェクトが、返却先で型変換される場合に、前記第1スタブに基づいて、前記オブジェクトの返却先での型変換に対応したオブジェクトを返却する第2スタブを生成し、
前記テスト対象プログラムにおいて、型変換を伴うクラスの呼び出しの対象を、前記第1スタブから、該第1スタブに基づいて生成された第2スタブに更新する
ことを含む処理をコンピュータが実行するスタブ生成方法。
(Appendix 4)
Generates a first stub that returns a dummy object in response to a class call from the program under test.
When the object returned from the generated first stub is type-converted at the return destination, the second stub that returns the object corresponding to the type conversion at the return destination of the object based on the first stub. To generate
In the test target program, a stub generation in which a computer executes a process including updating the target of a class call involving type conversion from the first stub to a second stub generated based on the first stub. Method.

(付記5)
前記第1スタブとして、前記クラスの型に応じたオブジェクトを返却する第1スタブを生成し、
前記第2スタブを、前記第1スタブにおいて、前記クラスの型に応じたオブジェクトを返却することを示す記述を、返却先の型変換時にエラーが発生しない型のオブジェクトを返却することを示す記述に書き換えることにより生成する
付記4に記載のスタブ生成方法。
(Appendix 5)
As the first stub, a first stub that returns an object according to the type of the class is generated.
The second stub is described in the first stub to indicate that an object corresponding to the type of the class is returned, and a description indicating that an object of a type that does not cause an error during type conversion of the return destination is returned. The stub generation method according to Appendix 4, which is generated by rewriting.

(付記6)
前記テスト対象プログラムから、型変換を伴うクラスの呼び出しを示す記述を抽出し、抽出した記述に含まれるクラスの呼び出しに対して生成された前記第1スタブを複製し、複製した第1スタブにおけるオブジェクトの返却に関する記述を書き換えることにより、前記第2スタブを生成する付記5に記載のスタブ生成方法。
(Appendix 6)
From the program under test, a description indicating a class call with type conversion is extracted, the first stub generated for the class call included in the extracted description is duplicated, and the object in the duplicated first stub is duplicated. The stub generation method according to Appendix 5, wherein the second stub is generated by rewriting the description regarding the return of the stub.

(付記7)
テスト対象プログラムからのクラスの呼び出しに対して、ダミーのオブジェクトを返却する第1スタブを生成し、
生成された第1スタブから返却されるオブジェクトが、返却先で型変換される場合に、前記第1スタブに基づいて、前記オブジェクトの返却先での型変換に対応したオブジェクトを返却する第2スタブを生成し、
前記テスト対象プログラムにおいて、型変換を伴うクラスの呼び出しの対象を、前記第1スタブから、該第1スタブに基づいて生成された第2スタブに更新する
ことを含む処理をコンピュータに実行させるためのスタブ生成プログラム。
(Appendix 7)
Generates a first stub that returns a dummy object in response to a class call from the program under test.
When the object returned from the generated first stub is type-converted at the return destination, the second stub that returns the object corresponding to the type conversion at the return destination of the object based on the first stub. To generate
In the test target program, for causing a computer to execute a process including updating the target of a class call involving type conversion from the first stub to a second stub generated based on the first stub. Stub generator.

(付記8)
前記第1スタブとして、前記クラスの型に応じたオブジェクトを返却する第1スタブを生成し、
前記第2スタブを、前記第1スタブにおいて、前記クラスの型に応じたオブジェクトを返却することを示す記述を、返却先の型変換時にエラーが発生しない型のオブジェクトを返却することを示す記述に書き換えることにより生成する
付記7に記載のスタブ生成プログラム。
(Appendix 8)
As the first stub, a first stub that returns an object according to the type of the class is generated.
The second stub is described in the first stub to indicate that an object corresponding to the type of the class is returned, and a description indicating that an object of a type that does not cause an error during type conversion of the return destination is returned. The stub generation program according to Appendix 7, which is generated by rewriting.

(付記9)
前記テスト対象プログラムから、型変換を伴うクラスの呼び出しを示す記述を抽出し、抽出した記述に含まれるクラスの呼び出しに対して生成された前記第1スタブを複製し、複製した第1スタブにおけるオブジェクトの返却に関する記述を書き換えることにより、前記第2スタブを生成する付記8に記載のスタブ生成プログラム。
(Appendix 9)
From the program under test, a description indicating a class call with type conversion is extracted, the first stub generated for the class call included in the extracted description is duplicated, and the object in the duplicated first stub is duplicated. The stub generation program according to Appendix 8, which generates the second stub by rewriting the description regarding the return of the stub.

(付記10)
テスト対象プログラムからのクラスの呼び出しに対して、ダミーのオブジェクトを返却する第1スタブを生成し、
生成された第1スタブから返却されるオブジェクトが、返却先で型変換される場合に、前記第1スタブに基づいて、前記オブジェクトの返却先での型変換に対応したオブジェクトを返却する第2スタブを生成し、
前記テスト対象プログラムにおいて、型変換を伴うクラスの呼び出しの対象を、前記第1スタブから、該第1スタブに基づいて生成された第2スタブに更新する
ことを含む処理をコンピュータに実行させるためのスタブ生成プログラムを記憶した記憶媒体。
(Appendix 10)
Generates a first stub that returns a dummy object in response to a class call from the program under test.
When the object returned from the generated first stub is type-converted at the return destination, the second stub that returns the object corresponding to the type conversion at the return destination of the object based on the first stub. To generate
In the test target program, for causing a computer to execute a process including updating the target of a class call involving type conversion from the first stub to a second stub generated based on the first stub. A storage medium that stores a stub generator.

10 スタブ生成装置
11 スタブ生成部
12 解析部
13 派生スタブ生成部
14 更新部
21 スタブ集合
22 キャスト集合
31 テスト対象クラス
41 オリジナルのクラス
42 スタブ
43 派生スタブ
60 コンピュータ
61 CPU
62 メモリ
63 記憶部
69 記憶媒体
70 スタブ生成プログラム
10 Stub generator 11 Stub generator 12 Analysis unit 13 Derived stub generator 14 Update unit 21 Stub set 22 Cast set 31 Test target class 41 Original class 42 Stub 43 Derived stub 60 Computer 61 CPU
62 Memory 63 Storage unit 69 Storage medium 70 Stub generation program

Claims (5)

テスト対象プログラムに含まれるメソッドから呼び出されるクラスをスタブ化し、ダミーのオブジェクトを返却する第1スタブを生成する第1生成部と、
前記第1生成部で生成された第1スタブから返却されるオブジェクトが、返却先で型変換される場合に、前記第1スタブに基づいて、前記オブジェクトの返却先での型変換が可能なオブジェクトを返却する第2スタブを生成する第2生成部と、
前記テスト対象プログラムにおいて、返却するオブジェクトが返却先で型変換されるクラスの呼び出しの対象を、前記第1スタブから、該第1スタブに基づいて生成された第2スタブに更新する更新部と、
を含むスタブ生成装置。
The class that is called from the method included in the test target program to stubbing, a first generator for generating a first stub to return a dummy object,
When the object returned from the first stub generated by the first generation unit is type-converted at the return destination, an object capable of type conversion at the return destination of the object based on the first stub. A second generator that generates a second stub that returns
In the test target program, an update unit that updates the target of the class in which the returned object is type-converted at the return destination from the first stub to the second stub generated based on the first stub.
Stub generator including.
前記第1生成部は、前記クラスの型に応じたオブジェクトを返却する第1スタブを生成し、
前記第2生成部は、前記第1スタブにおいて、前記クラスの型に応じたオブジェクトを返却することを示す記述を、返却先の型変換時にエラーが発生しない型のオブジェクトを返却することを示す記述に書き換えることにより第2スタブを生成する
請求項1に記載のスタブ生成装置。
The first generation unit generates a first stub that returns an object according to the type of the class.
In the first stub, the second generation unit includes a description indicating that an object corresponding to the type of the class is returned, and a description indicating that an object of a type that does not cause an error during type conversion of the return destination is returned. The stub generator according to claim 1, wherein the second stub is generated by rewriting the stub.
前記第2生成部は、前記テスト対象プログラムから、型変換を伴うクラスの呼び出しを示す記述を抽出し、抽出した記述に含まれるクラスの呼び出しに対して前記第1生成部で生成された前記第1スタブを複製し、複製した第1スタブにおけるオブジェクトの返却に関する記述を書き換えることにより、前記第2スタブを生成する請求項2に記載のスタブ生成装置。 The second generation unit extracts a description indicating a class call accompanied by type conversion from the test target program, and the first generation unit is generated for the class call included in the extracted description. The stub generator according to claim 2, wherein the second stub is generated by duplicating one stub and rewriting the description regarding the return of the object in the duplicated first stub. テスト対象プログラムに含まれるメソッドから呼び出されるクラスをスタブ化し、ダミーのオブジェクトを返却する第1スタブを生成し、
生成された第1スタブから返却されるオブジェクトが、返却先で型変換される場合に、前記第1スタブに基づいて、前記オブジェクトの返却先での型変換が可能なオブジェクトを返却する第2スタブを生成し、
前記テスト対象プログラムにおいて、返却するオブジェクトが返却先で型変換されるクラスの呼び出しの対象を、前記第1スタブから、該第1スタブに基づいて生成された第2スタブに更新する
ことを含む処理をコンピュータが実行するスタブ生成方法。
Stub the class called from the method included in the program under test, generate the first stub that returns a dummy object,
When the object returned from the generated first stub is type-converted at the return destination, the second stub that returns an object that can be type-converted at the return destination of the object based on the first stub. To generate
In the test target program, a process including updating the call target of the class whose return object is type-converted at the return destination from the first stub to the second stub generated based on the first stub. How to generate stubs that your computer does.
テスト対象プログラムに含まれるメソッドから呼び出されるクラスをスタブ化し、ダミーのオブジェクトを返却する第1スタブを生成し、
生成された第1スタブから返却されるオブジェクトが、返却先で型変換される場合に、前記第1スタブに基づいて、前記オブジェクトの返却先での型変換が可能なオブジェクトを返却する第2スタブを生成し、
前記テスト対象プログラムにおいて、返却するオブジェクトが返却先で型変換されるクラスの呼び出しの対象を、前記第1スタブから、該第1スタブに基づいて生成された第2スタブに更新する
ことを含む処理をコンピュータに実行させるためのスタブ生成プログラム。
Stub the class called from the method included in the program under test, generate the first stub that returns a dummy object,
When the object returned from the generated first stub is type-converted at the return destination, the second stub that returns an object that can be type-converted at the return destination of the object based on the first stub. To generate
In the test target program, a process including updating the call target of the class in which the returned object is type-converted at the return destination from the first stub to the second stub generated based on the first stub. A stub generator that lets your computer run.
JP2017044151A 2017-03-08 2017-03-08 Stub generators, methods, and programs Active JP6888336B2 (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
JP2017044151A JP6888336B2 (en) 2017-03-08 2017-03-08 Stub generators, methods, and programs

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
JP2017044151A JP6888336B2 (en) 2017-03-08 2017-03-08 Stub generators, methods, and programs

Publications (2)

Publication Number Publication Date
JP2018147388A JP2018147388A (en) 2018-09-20
JP6888336B2 true JP6888336B2 (en) 2021-06-16

Family

ID=63591355

Family Applications (1)

Application Number Title Priority Date Filing Date
JP2017044151A Active JP6888336B2 (en) 2017-03-08 2017-03-08 Stub generators, methods, and programs

Country Status (1)

Country Link
JP (1) JP6888336B2 (en)

Also Published As

Publication number Publication date
JP2018147388A (en) 2018-09-20

Similar Documents

Publication Publication Date Title
US7434101B2 (en) Highly specialized scenarios in random test generation
BR112016024522B1 (en) NON-TRANSITORY COMPUTER READABLE STORAGE MEDIA AND METHOD FOR SPECIALIZING A GENERIC CLASS
CN111796831B (en) Compiling method and device for multi-chip compatibility
US10146672B2 (en) Method and system for automated user interface (UI) testing through model driven techniques
US9983977B2 (en) Apparatus and method for testing computer program implementation against a design model
US10747653B2 (en) Software testing systems and methods
US20120131559A1 (en) Automatic Program Partition For Targeted Replay
US11720422B1 (en) Unified container for hardware and software binaries
CN110765008B (en) Data processing method and device
JP6888336B2 (en) Stub generators, methods, and programs
CN111475150A (en) Cross-language binding method, device, equipment and storage medium
US7533314B2 (en) Unit test extender
JP6512032B2 (en) Stub target determination apparatus, method, and program
JP2009087353A (en) System and method for generating closed homogeneous non-distributed application from open heterogeneous distributed application
Burger et al. Difference-based Conformance Checking for Ecore Metamodels
US10515029B2 (en) Conversion tool for moving from block-based persistence to byte-based persistence
US20080127075A1 (en) Method and system for enforcing version control
WO2023248364A1 (en) Program generating device, program generating method, and program generating program
Dappert et al. Digital preservation metadata practice for computing environments
JP2011145880A (en) Generation method for test task used in logic verification of semiconductor integrated circuit
CN116541013A (en) Compiling method, computing device and storage medium
JP2005301415A (en) Compile system, simulator, emulator, and program development supporting system
JP6143038B1 (en) OS program and method for accessing file without depending on application
Lin et al. Justifying the transition from trustworthiness to resiliency via generation of safety cases
KR20040096238A (en) Method And System for Checking Exception of API on Source Code Level

Legal Events

Date Code Title Description
A621 Written request for application examination

Free format text: JAPANESE INTERMEDIATE CODE: A621

Effective date: 20191112

A977 Report on retrieval

Free format text: JAPANESE INTERMEDIATE CODE: A971007

Effective date: 20200916

A131 Notification of reasons for refusal

Free format text: JAPANESE INTERMEDIATE CODE: A131

Effective date: 20201020

A521 Written amendment

Free format text: JAPANESE INTERMEDIATE CODE: A523

Effective date: 20201124

TRDD Decision of grant or rejection written
A01 Written decision to grant a patent or to grant a registration (utility model)

Free format text: JAPANESE INTERMEDIATE CODE: A01

Effective date: 20210420

A61 First payment of annual fees (during grant procedure)

Free format text: JAPANESE INTERMEDIATE CODE: A61

Effective date: 20210503

R150 Certificate of patent or registration of utility model

Ref document number: 6888336

Country of ref document: JP

Free format text: JAPANESE INTERMEDIATE CODE: R150