JP2018147388A - Stub generator, method, and program - Google Patents

Stub generator, method, and program Download PDF

Info

Publication number
JP2018147388A
JP2018147388A JP2017044151A JP2017044151A JP2018147388A JP 2018147388 A JP2018147388 A JP 2018147388A JP 2017044151 A JP2017044151 A JP 2017044151A JP 2017044151 A JP2017044151 A JP 2017044151A JP 2018147388 A JP2018147388 A JP 2018147388A
Authority
JP
Japan
Prior art keywords
stub
class
type
generated
generation unit
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.)
Granted
Application number
JP2017044151A
Other languages
Japanese (ja)
Other versions
JP6888336B2 (en
Inventor
スッパシット モンプラターンチャイ
Monpratarnchai Supasit
スッパシット モンプラターンチャイ
竜一 梅川
Ryuichi Umekawa
竜一 梅川
忠弘 上原
Tadahiro Uehara
忠弘 上原
裕介 佐々木
Yusuke Sasaki
裕介 佐々木
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

Landscapes

  • Debugging And Monitoring (AREA)

Abstract

PROBLEM TO BE SOLVED: To provide a stub generator that generates a stub for suppressing a reduction of test coverage in symbolic execution of a program under test that includes conversion of object types.SOLUTION: In a stub generator 10, a stub generation unit 11 generates a stub that returns a dummy object in response to class invocation from a class under test. When an object returned from an original stub has its type converted at the return destination, a derived stub generation unit 13 generates a derived stub, on the basis of the stub, that returns an object that corresponds to the type conversion at the return destination of the object. An updating unit 14 updates, in the program under test, the subject of invocation of a class that involves type conversion from an original stub to a derived stub generated on the basis of the original stub.SELECTED DRAWING: Figure 1

Description

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

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

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

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

特開2009−129133号公報JP 2009-129133 A 特開2012−181666号公報JP 2012-181666 A

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

しかし、スタブから返却されるオブジェクトの型と、返却先のクラスの型との継承関係によっては、返却されたオブジェクトに対象プログラムがアクセスした際にエラーとなってしまう場合がある。この場合、対象プログラムのテストの実行がその時点で中断してしまい、テスト網羅性が低下してしまう。   However, depending on the inheritance relationship between the object type 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 time, and the test coverage is deteriorated.

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

開示の技術は、一つの態様として、第1生成部が、テスト対象プログラムからのクラスの呼び出しに対して、ダミーのオブジェクトを返却する第1スタブを生成する。第2生成部が、前記第1生成部で生成された第1スタブから返却されるオブジェクトが、返却先で型変換される場合に、前記第1スタブに基づいて、前記オブジェクトの返却先での型変換に対応したオブジェクトを返却する第2スタブを生成する。更新部が、前記テスト対象プログラムにおいて、型変換を伴うクラスの呼び出しの対象を、前記第1スタブから、該第1スタブに基づいて生成された第2スタブに更新する。   As an aspect of the disclosed technology, the first generation unit generates a first stub that returns a dummy object in response to a class call from a test target program. When the object returned from the first stub generated by the first generator is type-converted at the return destination, the second generator is based on the first stub at the return destination of the object. A second stub that returns an object corresponding to type conversion is generated. The updating unit updates the class call target accompanied with type conversion in the test target program from the first stub to the second stub generated based on the first stub.

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

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

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

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

ここで、シンボリック実行技術を用いたプログラムの単体テストの手順について説明する。   Here, the procedure of the unit test of the program using the symbolic execution technique 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 constructs and sets the execution environment of the test target class 31 and starts the test target class. A stub is a dummy implementation of a program component called by a test target class. The program component called from the test target class may be in the process of being mounted or the program component may not be tested at the test stage of the test target class. In addition, the program component may execute external access to a file, a database, or the like. For this reason, when a program part called from a test target class cannot be used during a test, a stub is used instead of the actual program part.

次に、生成したシンボリック実行ドライバ及びスタブと、テスト対象クラスとをシンボリック実行エンジン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 using the generated test case, the unit test tool 201 executes a test, thereby obtaining a test result for the test target class (S103).

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

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

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

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

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

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

上記(2)は、インスタンス化した子クラス「Child」のオブジェクトを親クラス「Parent」へキャストし、キャストしたオブジェクトを子クラス「Child」にキャストしている。すなわち、上記(2)はアップキャスト後のダウンキャストを表しており、このようなクラスキャストは可能である。   In the above (2), the instantiated object of the child class “Child” 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 down-casting the instantiated object of the parent class “Parent” to the child class “Child”, and such class casting is not possible.

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

図6に示すように、テスト対象クラスから呼び出されるオリジナルのクラスからは、子クラス「Child」から親クラス「Parent」にアップキャストされたオブジェクトpが返却される。返却先では、親クラス「Parent」のオブジェクトpが子クラス「Child」にキャストされる。この場合、アップキャスト後のダウンキャストであるため、クラスキャストが可能である。   As shown in FIG. 6, from the original class called from the test target class, the object p up-casted from the child class “Child” to the parent class “Parent” is returned. 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 upcasting, class casting is possible.

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

そこで、本実施形態では、オブジェクトの返却先でのクラスキャストに応じたオブジェクトを返却するスタブを生成する。以下、スタブ生成装置10の各部について詳述する。   Therefore, in this embodiment, a stub that returns an object corresponding to the class cast at the return destination of the object is generated. Hereinafter, each part of the stub generation device 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 derived stub generation unit 13, and an update unit 14. The stub generation unit 11 is an example of a first generation unit according to the disclosed technique, and the analysis unit 12 and the derived stub generation unit 13 are examples of a second generation unit according to the disclosed technique.

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

解析部12は、スタブ生成部11で生成されたスタブから返却されるオブジェクトが、テスト対象クラスの返却先においてクラスキャストされる箇所を特定する。   The analysis unit 12 specifies 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 class names (hereinafter referred to as “stub class names”) of stubs (stubbed classes) generated by the stub generation unit 11 and stores them in the stub set 21. In addition, the analysis unit 12 calls out 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 objects returned from the stub are cast. The analysis unit 12 obtains information on the object cast destination class, the stub class name of the called stub, and the method name of the method calling the stub from each extracted statement. The analysis unit 12 creates a record from the acquired information and stores it in the cast set 22.

派生スタブ生成部13は、返却先でクラスキャストされるオブジェクトを返却するスタブから、キャスト先のクラスに応じたオブジェクトを返却するスタブを派生させて生成する。以下、派生スタブ生成部13で生成するスタブを「派生スタブ」という。   The derivation stub generation unit 13 generates a stub that returns an object corresponding to a cast destination class from 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 “derived stub”.

具体的には、派生スタブ生成部13は、キャスト集合22に格納された各レコードに含まれるスタブクラス名が示すスタブのコードを複製して、スタブクラス名を派生スタブであることを表す名前に変更する。例えば、派生スタブ生成部13は、派生スタブのスタブクラス名を、元のスタブのスタブクラス名の後に「派生i」を付加した名前に変更することができる。iは、派生スタブを生成する毎に、0からカウントアップされる整数とすることができる。また、派生スタブ生成部13は、生成した派生スタブのスタブクラス名を、キャスト集合22における該当のレコードに追加する。   Specifically, the derived stub generation unit 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 in which “derivative i” is added after the stub class name of the original stub. i can be an integer counting up from 0 each time a derived stub is generated. In addition, 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の記述を修正する。   Also, the derived stub generation unit 13 modifies the description of return in the body part of the callee method in the derived stub so as to instantiate and return an object corresponding to the cast destination class.

更新部14は、テスト対象クラスにおいて、キャスト集合22に格納された各レコードの情報に相当するステートメントを検出する。更新部14は、検出したステートメントにおいて呼び出すスタブのスタブクラス名を、該当のレコードに含まれる派生スタブのスタブクラス名に更新する。   The update unit 14 detects a statement corresponding to information of each record stored in the cast set 22 in the test target class. The updating unit 14 updates the stub class name of the stub 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 generation device 10 can be realized, for example, by a 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 nonvolatile storage unit 63. 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 with respect to the storage medium 69, and a network such as the Internet. A 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 a 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 and expands it in 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 illustrated in FIG. 1 by executing the stub generation process 71. Further, the CPU 61 operates as the analysis unit 12 illustrated in FIG. 1 by executing the analysis process 72. Further, the CPU 61 operates as the derived stub generation unit 13 illustrated in FIG. 1 by executing the derived stub generation process 73. The CPU 61 operates as the update unit 14 illustrated 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 be realized by, for example, a semiconductor integrated circuit, more specifically, an application specific integrated circuit (ASIC).

次に、本実施形態に係るスタブ生成装置10の作用について説明する。スタブ生成装置10にテスト対象クラスが入力されると、スタブ生成装置10において、図8に示すスタブ生成処理が実行される。なお、ここでは、図9に示すようなクラス間の継承関係が定義されたテスト対象クラスが入力されるものとする。図9は、親クラス「果物」を継承する子クラス「みかん」及び「バナナ」と、親クラス「動物」を継承する子クラス「猫」及び「犬」とが定義されている例を示している。また、図10に示すように、テスト対象クラス31のメソッドから呼び出されるユーザ定義クラスとして、クラス41A(クラス名「スタブA」)及びクラス41B(クラス名「スタブB」)が定義されている。以下では、このオリジナルのクラス41A及び41Bをスタブ化対象クラスとする場合について説明する。   Next, the operation of the stub generation device 10 according to this embodiment will be described. When the test target class is input to the stub generation device 10, the stub generation processing shown in FIG. 8 is executed in the stub generation device 10. Here, it is assumed that a test target class in which an inheritance relationship between classes as shown in FIG. 9 is defined is input. FIG. 9 shows an example in which child classes “mandarin orange” and “banana” that inherit the parent class “fruit” and child classes “cat” and “dog” that inherit the parent class “animal” are defined. Yes. Also, as shown in FIG. 10, a class 41A (class name “stub A”) and a 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 these 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 converts the original classes 41A and 41B to be stubbed into stubs, and stub 42A (stub class name “stub A”) and stub 42B (stub class name). “Stub B”). Here, as shown in FIG. 11, stubs 42A and 42B that return instances of return type objects of methods that call the original class are generated.

次に、ステップS12で、解析部12が、スタブ生成部11により生成されたスタブのスタブクラス名をスタブ集合21に格納する。ここでは、スタブクラス名「スタブA」及び「スタブB」がスタブ集合21に格納される。   Next, in step S <b> 12, 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 objects returned from the stub are cast. To do. The analysis unit 12 can extract, for example, a statement including a description indicating a cast (in this embodiment, a description indicating a cast destination class in () like “(Mikan)”).

次に、ステップS14で、解析部12が、抽出した各ステートメントから、オブジェクトのキャスト先のクラス、呼び出されるスタブのスタブクラス名、及びそのスタブを呼び出すメソッドのメソッド名の情報を取得する。例えば、図12に示すように、本実施形態では、解析部12は、ステートメント中の( )内からキャスト先のクラスを取得し、それに続く記述の「.(ドット)」の前部分をスタブクラス名、後部分をメソッド名として取得することができる。   Next, in step S14, the analysis unit 12 acquires information on the object cast destination class, the stub class name of the stub to be called, and the method name of the method that calls the stub from each extracted statement. For example, as shown in FIG. 12, in this embodiment, the analysis unit 12 acquires a cast destination class from within () in a statement, and sets the preceding part of “. (Dot)” in the subsequent description as a stub class. Name and back part can be obtained as 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. Note that the statement on the third line of the test target class 31 (broken line portion in FIG. 13) does not include the description indicating the cast, and thus is not extracted in step S13.

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

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

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

次に、ステップ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 a derived stub. As shown in FIG. 14, when the record 51 to be processed (record on the first line of the cast set 22 shown in FIG. 13) is set, the stub 42A (stub class name “stub” from the “stub class name” of the record 51 is set. A ") is identified. The stub 42A is duplicated to generate a derived stub 43A.

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

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

次に、ステップ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 indicated by an 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 derived stub generation unit 13 increments the variable i by 1, and the process returns to step S16. In the present embodiment, from the records in the second row of the cast set 22 shown in FIG. 13, the stub A derivation 1 from the third row record to the stub A derivation 2 and the records in the fourth row are performed by repeating the steps S16 to S22. Stub B derivation 3 is generated. If it is determined in step S16 that i has exceeded 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 S <b> 23, 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 illustrated 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 the 4th to 7th lines in FIG. 15, the stub to be called is updated to the derived stub generated by the derived stub generation unit 13. In the statement on the third line, since the return object is not cast, the stub to be called is the original stub generated by the stub generation unit 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 derived 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. The 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. Also, the derivation stub 43A1 (stub class name “stub A derivation 1”) is called from the statement on the fifth line. Further, the stub 43A2 (stub class name “stub A derivation 2”) is called from the statement on the sixth line. Also, the derivation stub 43B (stub class name “stub B derivation 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 generation device according to the present embodiment generates a stub that is a dummy of a class called from a method of a test target class. When this stub is used as it is, as shown in FIG. 17, an object returned from the stub is 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 corresponding to the cast destination class is generated from the original stub. Then, the stub to be called is updated to the derived stub in the test target class. Thereby, generation | occurrence | production of a downcast can be suppressed. When calling a class 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 coverage.

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

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

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

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

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

(付記2)
前記第1生成部は、前記クラスの型に応じたオブジェクトを返却する第1スタブを生成し、
前記第2生成部は、前記第1スタブにおいて、前記クラスの型に応じたオブジェクトを返却することを示す記述を、返却先の型変換時にエラーが発生しない型のオブジェクトを返却することを示す記述に書き換えることにより第2スタブを生成する
付記1に記載のスタブ生成装置。
(Appendix 2)
The first generation unit generates a first stub that returns an object corresponding 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 at the time of type conversion of the return destination is returned. The stub generation device according to attachment 1, wherein the second stub is generated by rewriting to

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

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

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

(付記7)
テスト対象プログラムからのクラスの呼び出しに対して、ダミーのオブジェクトを返却する第1スタブを生成し、
生成された第1スタブから返却されるオブジェクトが、返却先で型変換される場合に、前記第1スタブに基づいて、前記オブジェクトの返却先での型変換に対応したオブジェクトを返却する第2スタブを生成し、
前記テスト対象プログラムにおいて、型変換を伴うクラスの呼び出しの対象を、前記第1スタブから、該第1スタブに基づいて生成された第2スタブに更新する
ことを含む処理をコンピュータに実行させるためのスタブ生成プログラム。
(Appendix 7)
Generate a first stub that returns a dummy object in response to a class call from the test target program,
The second stub that returns an object corresponding to the type conversion at the return destination of the object based on the first stub when the object returned from the generated first stub is type-converted at the return destination. Produces
In the test target program, for causing a computer to execute a process including updating a target of a class call accompanied by 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, generate a first stub that returns an object corresponding to the type of the class,
In the first stub, the second stub is replaced with 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 at the time of 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)
A description indicating class call accompanied by type conversion is extracted from the test target program, the first stub generated for the class call included in the extracted description is copied, and the object in the copied first stub is copied The stub generation program according to supplementary note 8, wherein the second stub is generated by rewriting a description related to return of the stub.

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

10 スタブ生成装置
11 スタブ生成部
12 解析部
13 派生スタブ生成部
14 更新部
21 スタブ集合
22 キャスト集合
31 テスト対象クラス
41 オリジナルのクラス
42 スタブ
43 派生スタブ
60 コンピュータ
61 CPU
62 メモリ
63 記憶部
69 記憶媒体
70 スタブ生成プログラム
DESCRIPTION OF SYMBOLS 10 Stub production | generation apparatus 11 Stub production | generation part 12 Analysis part 13 Derived stub production | generation part 14 Update part 21 Stub set 22 Cast set 31 Test object 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スタブに更新する更新部と、
を含むスタブ生成装置。
A first generation unit that generates a first stub that returns a dummy object in response to a class call from a test target program;
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 for generating a second stub for returning
In the test target program, an update unit that updates a target of a class call accompanied by type conversion from the first stub to a second stub generated based on the first stub;
A stub generator.
前記第1生成部は、前記クラスの型に応じたオブジェクトを返却する第1スタブを生成し、
前記第2生成部は、前記第1スタブにおいて、前記クラスの型に応じたオブジェクトを返却することを示す記述を、返却先の型変換時にエラーが発生しない型のオブジェクトを返却することを示す記述に書き換えることにより第2スタブを生成する
請求項1に記載のスタブ生成装置。
The first generation unit generates a first stub that returns an object corresponding 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 at the time of type conversion of the return destination is returned. The stub generation device according to claim 1, wherein the second stub is generated by rewriting to:
前記第2生成部は、前記テスト対象プログラムから、型変換を伴うクラスの呼び出しを示す記述を抽出し、抽出した記述に含まれるクラスの呼び出しに対して前記第1生成部で生成された前記第1スタブを複製し、複製した第1スタブにおけるオブジェクトの返却に関する記述を書き換えることにより、前記第2スタブを生成する請求項2に記載のスタブ生成装置。   The second generation unit extracts a description indicating class call accompanied by type conversion from the test target program, and the first generation unit generated by the first generation unit with respect to the class call included in the extracted description The stub generation device according to claim 2, wherein the second stub is generated by duplicating one stub and rewriting a description related to returning an object in the copied first stub. テスト対象プログラムからのクラスの呼び出しに対して、ダミーのオブジェクトを返却する第1スタブを生成し、
生成された第1スタブから返却されるオブジェクトが、返却先で型変換される場合に、前記第1スタブに基づいて、前記オブジェクトの返却先での型変換に対応したオブジェクトを返却する第2スタブを生成し、
前記テスト対象プログラムにおいて、型変換を伴うクラスの呼び出しの対象を、前記第1スタブから、該第1スタブに基づいて生成された第2スタブに更新する
ことを含む処理をコンピュータが実行するスタブ生成方法。
Generate a first stub that returns a dummy object in response to a class call from the test target program,
The second stub that returns an object corresponding to the type conversion at the return destination of the object based on the first stub when the object returned from the generated first stub is type-converted at the return destination. Produces
In the test target program, a stub generation in which a computer executes processing including updating a target of a class call accompanied by type conversion from the first stub to a second stub generated based on the first stub Method.
テスト対象プログラムからのクラスの呼び出しに対して、ダミーのオブジェクトを返却する第1スタブを生成し、
生成された第1スタブから返却されるオブジェクトが、返却先で型変換される場合に、前記第1スタブに基づいて、前記オブジェクトの返却先での型変換に対応したオブジェクトを返却する第2スタブを生成し、
前記テスト対象プログラムにおいて、型変換を伴うクラスの呼び出しの対象を、前記第1スタブから、該第1スタブに基づいて生成された第2スタブに更新する
ことを含む処理をコンピュータに実行させるためのスタブ生成プログラム。
Generate a first stub that returns a dummy object in response to a class call from the test target program,
The second stub that returns an object corresponding to the type conversion at the return destination of the object based on the first stub when the object returned from the generated first stub is type-converted at the return destination. Produces
In the test target program, for causing a computer to execute a process including updating a target of a class call accompanied by type conversion from the first stub to a second stub generated based on the first stub. Stub generator.
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 true JP2018147388A (en) 2018-09-20
JP6888336B2 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
JP6888336B2 (en) 2021-06-16

Similar Documents

Publication Publication Date Title
US10394694B2 (en) Unexplored branch search in hybrid fuzz testing of software binaries
CN104714788B (en) A kind of method and device that software installation packet automatically generates
BR112016024522B1 (en) NON-TRANSITORY COMPUTER READABLE STORAGE MEDIA AND METHOD FOR SPECIALIZING A GENERIC CLASS
CN111399853A (en) Templated deployment method of machine learning model and custom operator
CN108196876B (en) PHP service configuration method based on file and central server
US20120131559A1 (en) Automatic Program Partition For Targeted Replay
JP2005529384A5 (en)
US8584080B2 (en) Modeling and generating computer software product line variants
JP7131277B2 (en) System migration support device, system migration support method and program
CN111367512B (en) Method and device for creating Android library module dependency relationship in application development
JPWO2020075282A1 (en) Conversion method, conversion device and conversion program
US7036045B2 (en) Method and system for isolating exception related errors in Java JVM
CN116578282A (en) Code generation method, device, electronic equipment and medium
JP6888336B2 (en) Stub generators, methods, and programs
US9032372B2 (en) Runtime environment and method for non-invasive monitoring of software applications
JP7025104B2 (en) Information processing equipment, methods and programs
CN109298883A (en) A kind of automatically generate component file method and electronic equipment under teaching platform
CN113177292B (en) Universal BIM secondary development implementation method and device
US20190244151A1 (en) Just in time compilation (jit) for business process execution
Wille Presenting C
WO2008015110A2 (en) Methods, apparatus and computer programs for modelling computer programs
US20240012639A1 (en) Method of programming a software module associated with a firmware unit of a device
CN117234466B (en) Enterprise management software development method, system, equipment and storage medium
Dappert et al. Digital preservation metadata practice for computing environments
JP2005301415A (en) Compile system, simulator, emulator, and program development supporting system

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