JP6533484B2 - Test data generation program and test data generation method - Google Patents
Test data generation program and test data generation method Download PDFInfo
- Publication number
- JP6533484B2 JP6533484B2 JP2016085943A JP2016085943A JP6533484B2 JP 6533484 B2 JP6533484 B2 JP 6533484B2 JP 2016085943 A JP2016085943 A JP 2016085943A JP 2016085943 A JP2016085943 A JP 2016085943A JP 6533484 B2 JP6533484 B2 JP 6533484B2
- Authority
- JP
- Japan
- Prior art keywords
- test
- test data
- branch
- scenario
- character string
- 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
Links
Images
Description
本発明は、テストデータ生成プログラム及びテストデータ生成方法に関し、特に、SBST(Search-Based Software Testing)の遺伝的アルゴリズムにおいて文字列の分岐条件に対応したテストデータを生成する技術に関する。 The present invention relates to a test data generation program and a test data generation method, and more particularly, to a technology for generating test data corresponding to a branch condition of a character string in a genetic algorithm of Search-Based Software Testing (SBST).
ソフトウェア開発工程におけるテストでは、プログラムが設計通りに実行するか否かを確認するため、テストケースが必要となる。人手に代わり、自動でテストケースを準備できれば、開発コスト改善につながる。 Tests in the software development process require test cases to check whether the program executes as designed. If you can prepare test cases automatically instead of manually, you can improve development costs.
テストケースはテストの手順を表すテストシナリオと、テストシナリオを実現するための具体的なデータであるテストデータから構成されている。 A test case is composed of a test scenario representing a test procedure and test data which is specific data for realizing the test scenario.
テストケースを生成するために、プログラムの設計に基づきテストシナリオやテストデータを自動的に生成する手法が検討されている。 In order to generate test cases, methods for automatically generating test scenarios and test data based on program design are being considered.
非特許文献1では、入力値定義及び処理フロー図を入力とし、テストシナリオとテストデータ(整数型、文字列型)を生成することが提案されている。
In
また、非特許文献2では、SBSTの探索アルゴリズムとして遺伝的アルゴリズムを用いてテストデータを生成することが提案されている。
In addition, Non-Patent
また、非特許文献3では、Concolic TestingとSBSTとを組み合わせたテストデータ生成技術が提案されている。
In addition, Non-Patent
プログラムが設計通りに実行するか否かを確認するためには、どのような手順でテストを実行するかというテストシナリオと、テストシナリオで用いられる具体的な入力値であるテストデータとの双方が必要となる。ここで、あるテストシナリオが与えられたときに、ソースコード上の分岐を網羅的に通過するテストデータの集合を効率的に生成することが求められる。分岐には数値の比較によって分岐するものと、文字列の比較によって分岐するものが存在するが、文字列の比較による分岐条件についても網羅性を高める必要がある。 In order to confirm whether the program executes as designed, both the test scenario of how to execute the test and the test data, which are specific input values used in the test scenario, are used. It will be necessary. Here, given a test scenario, it is required to efficiently generate a set of test data that comprehensively passes through a branch on the source code. There are two types of branches: those that branch based on comparison of numerical values and those that branch based on comparison of character strings. However, it is necessary to improve the coverage also for the branch condition based on comparison of character strings.
非特許文献1の技術によれば、入力値定義や処理フロー図を人手で作成する必要があるため、テストシナリオ及びテストデータを効率的に生成することは困難である。
According to the technique of Non-Patent
また、非特許文献2の技術によれば、テスト対象のメソッド内で静的解析によって事前に取得した定数を使用してテストデータを生成するが、結合テストレベルでは網羅性を高めることができない。また、定数の取得場所を考慮していないため、解きたい分岐との関連性の薄い定数を選択する可能性がある。
Further, according to the technique of Non-Patent
また、非特許文献3の技術によれば、Concolic Testing及びSBSTの2つの手法が順番に実行されるだけであるため、テストデータの生成に時間がかかる。更に、一般的にSBSTでは文字列のデータ型を含む分岐に対してテストデータを生成することは困難である。
Further, according to the technique of Non-Patent
本発明は、あるテストシナリオが与えられたときに、文字列のデータ型を含む分岐に対して網羅性の高いテストデータの集合を効率的に生成することを目的とする。 An object of the present invention is to efficiently generate an exhaustive set of test data for a branch including a data type of a string given a test scenario.
本発明の一形態に係るテストデータ生成プログラムは、
指定のテストシナリオに対するテストデータを生成するテストデータ生成プログラムであって、コンピュータに、
テストデータの生成に用いられる文字列の集合を取得する文字列集合取得機能と、
テスト対象のプログラムに、分岐の判定を定量的に評価するための評価値を含む分岐結果を出力するコードを挿入するコード挿入機能と、
指定のテストシナリオに対するテストデータを生成すると共に、前記挿入されたコードが出力した分岐結果を生成する第1テストデータ生成機能と、
前記生成された分岐結果に対して途中まで経路一致する目標分岐結果を生成し、前記取得された文字列の集合の中から選択された文字列を遺伝的アルゴリズムにおいて用いて、当該目標分岐結果を満たすテストデータを生成する第2のテストデータ生成機能と、
を実現させることを特徴とする。
A test data generation program according to an aspect of the present invention is
A test data generation program for generating test data for a specified test scenario, the computer comprising:
A character string set acquisition function for acquiring a set of character strings used to generate test data;
A code insertion function for inserting into the program to be tested a code that outputs a branch result including an evaluation value for quantitatively evaluating the determination of the branch;
A first test data generation function of generating test data for a specified test scenario and generating a branch result output from the inserted code;
A target branch result that matches the path halfway to the generated branch result is generated, and a character string selected from among the acquired character string set is used in a genetic algorithm, and the target branch result is generated. A second test data generation function for generating test data to be satisfied;
To realize.
また、本発明の一形態に係るテストデータ生成方法は、
指定のテストシナリオに対するテストデータを生成するテストデータ生成装置におけるテストデータ生成方法であって、
前記テストデータ生成装置が、テストデータの生成に用いられる文字列の集合を取得するステップと、
前記テストデータ生成装置が、テスト対象のプログラムに、分岐の判定を定量的に評価するための評価値を含む分岐結果を出力するコードを挿入するステップと、
前記テストデータ生成装置が、指定のテストシナリオに対するテストデータを生成すると共に、前記挿入されたコードが出力した分岐結果を生成するステップと、
前記テストデータ生成装置が、前記生成された分岐結果に対して途中まで経路一致する目標分岐結果を生成し、前記取得された文字列の集合の中から選択された文字列を遺伝的アルゴリズムにおいて用いて、当該目標分岐結果を満たすテストデータを生成するステップと、
を有することを特徴とする。
In addition, a test data generation method according to an aspect of the present invention is
A test data generation method in a test data generation apparatus for generating test data for a specified test scenario, comprising:
The test data generation device acquiring a set of character strings used for generation of test data;
Inserting, in the program to be tested, a code that outputs a branch result including an evaluation value for quantitatively evaluating the determination of a branch, into the program to be tested;
The test data generator generating test data for a specified test scenario and generating a branch result output from the inserted code;
The test data generation device generates a target branch result that matches the path halfway to the generated branch result, and uses a character string selected from the acquired character string set in a genetic algorithm Generating test data satisfying the target branch result;
It is characterized by having.
本発明によれば、あるテストシナリオが与えられたときに、文字列のデータ型を含む分岐に対して網羅性の高いテストデータの集合を効率的に生成することが可能になる。 According to the present invention, given a test scenario, it is possible to efficiently generate an exhaustive set of test data for a branch including a data type of a character string.
以下、図面を参照して本発明の実施例について説明する。 Hereinafter, embodiments of the present invention will be described with reference to the drawings.
本発明の実施例では、プログラムのテストシナリオ及びテストデータの組み合わせであるテストケースを生成するテストケース生成プログラム及びテストケース生成方法について説明する。なお、テストケース生成プログラムに関する説明の便宜上、プログラムの各機能をコンピュータ上に実現したテストケース生成装置を例に挙げて説明する。 In the embodiment of the present invention, a test case generation program and a test case generation method for generating a test case which is a combination of a test scenario of a program and test data will be described. In addition, for convenience of the description regarding a test case production | generation program, the test case production | generation apparatus which implement | achieved each function of the program on the computer is mentioned as an example, and is demonstrated.
以下の実施例ではテストシナリオの生成から説明するが、本発明の実施例は、テストシナリオが指定されたときに、指定のテストシナリオに対するテストデータを生成するテストデータ生成プログラム及びテストデータ生成方法としても実現できる。 Although the following embodiment will be described from the generation of a test scenario, the embodiment of the present invention is a test data generation program and test data generation method for generating test data for a specified test scenario when a test scenario is specified. Can also be realized.
テストケース生成装置は、Webアプリケーションのようなユーザインタフェースをもつアプリケーションのプログラムをテスト対象として、テストシナリオを生成する。このようなアプリケーションは、MVC(Model View Controller)に従って設計され、少なくともView及びControllerで構成される。Modelは、アプリケーションが扱うデータ及びロジックを表現するための要素であり、Viewは、入出力や表示を行うための要素であり、Controllerは、Viewからの入力に応じて必要なロジックの実行をModelに依頼し、その結果表示をViewに依頼するための要素である。MVCに従って設計されたプログラムでは、Controllerの情報を用いてView間の繋がりが抽出できる。テストケース生成装置は、View間の繋がりを表すViewの遷移図から状態遷移図に対する所定のカバレッジ基準に基づいてView及びControllerの繋がりを表すVCシナリオを生成する。 The test case generation apparatus generates a test scenario with a program of an application having a user interface such as a Web application as a test target. Such an application is designed in accordance with a model view controller (MVC), and is configured with at least a view and a controller. Model is an element for expressing data and logic handled by the application, View is an element for performing input / output and display, and Controller is for executing the necessary logic according to the input from View. It is an element to ask for and ask for View to display the result. In a program designed according to MVC, the connection between Views can be extracted using the information of Controller. The test case generation apparatus generates a VC scenario representing the connection of View and Controller based on a predetermined coverage criterion for the state transition diagram from the transition diagram of View representing the connection between Views.
テストケース生成装置は、生成されたVCシナリオを満たすようなテストデータを、テスト対象のプログラムを動かしながら生成する。一方、ViewとControllerの名前の羅列から構成されるVCシナリオの情報だけでは、どういった操作を行えば良いかわからない。そこで、テストケース生成装置は、クローラやユーザ操作等によってVCシナリオにView操作情報を加えることで、テストシナリオを生成する。 The test case generation device generates test data that satisfies the generated VC scenario while moving a program to be tested. On the other hand, VC scenario information consisting of a list of View and Controller names alone does not know what to do. Therefore, the test case generation apparatus generates a test scenario by adding View operation information to a VC scenario by a crawler or user operation.
次に、テストケース生成装置は、生成されたテストシナリオのうち1つのシナリオを指定して、以下のようにテストデータを生成する。 Next, the test case generation apparatus generates test data as follows by specifying one of the generated test scenarios.
テストケース生成装置は、分岐に対する評価値を解析することによりテストデータを生成するテストデータ生成手法を用いてテストデータを生成する。このようなテストデータ生成手法の具体的な例は、SBSTである。SBSTとは、分岐の判定を定量的に評価するための評価値を解析することによりテストデータを生成するテストデータ生成手法である。例えば、入力値>0という分岐に対して(0-入力値)という評価関数を設計し、評価関数の評価値を解析することで、分岐条件を満たすテストデータを生成する。 The test case generation apparatus generates test data using a test data generation method of generating test data by analyzing evaluation values for branches. A specific example of such a test data generation method is SBST. The SBST is a test data generation method that generates test data by analyzing an evaluation value for quantitatively evaluating the determination of a branch. For example, an evaluation function of (0-input value) is designed for a branch of input value> 0, and the evaluation value of the evaluation function is analyzed to generate test data satisfying the branch condition.
以下では、SBSTを用いた具体例を説明する。 Hereinafter, a specific example using SBST will be described.
SBSTでは、分岐の評価値が用いられるため、まず、テストケース生成装置は、テスト対象のプログラムに、分岐の判定を定量的に評価するための評価値を含む分岐結果を出力するコードを挿入する。そして、テストケース生成装置は、Concolic TestingやSBSTによって、指定のテストシナリオに対するテストデータを生成すると共に、挿入されたコードが出力した分岐結果を生成する。なお、Concolic Testingとは、入力値を記号に置き換えて得られた制約式を解析することによりテストデータを生成するテストデータ生成手法である。例えば、入力値>0という分岐に対して具体的な数値を用いる代わりに、数値を記号xに置き換えてx>0という制約式を解析することにより、分岐条件を満たすテストデータを生成する。 In SBST, since the evaluation value of the branch is used, the test case generation apparatus first inserts a code for outputting a branch result including an evaluation value for quantitatively evaluating the determination of the branch into the program to be tested. . Then, the test case generation apparatus generates test data for the specified test scenario by Concolic Testing or SBST, and generates a branch result output from the inserted code. Concolic Testing is a test data generation method for generating test data by analyzing a constraint expression obtained by replacing input values with symbols. For example, instead of using a specific numerical value for the branch of input value> 0, test data satisfying the branch condition is generated by replacing the numerical value with the symbol x and analyzing the constraint expression of x> 0.
一方、分岐の評価値だけでは文字列のデータ型を含む分岐を解析することが困難である。そこで、テストケース生成装置は、テスト対象のプログラムに対して、静的解析、動的解析又は事前準備によって生成された文字列の集合である、String Poolを作成する。静的解析とは、プログラムのソースコード又はバイトコードにおいて、文字列のデータ型の一致判定に用いられている定数を解析することを意味する。また、動的解析とは、テスト対象のプログラムを実行している際に、文字列のデータ型の一致判定に用いられている定数を解析することを意味する。例えば、A.equals(B)というString型の一致判定がある場合、静的解析又は動的解析によって定数BがString Poolに追加される。事前準備とは、入力値や分岐として使われる可能性がある文字列を予め準備することを意味する。例えば、住所が入力値として使われる場合、事前準備によって「東京都千代田区」等の文字列がString Poolに追加される。 On the other hand, it is difficult to analyze a branch including the data type of a character string using only the evaluation value of the branch. Therefore, the test case generation apparatus generates a String Pool, which is a set of character strings generated by static analysis, dynamic analysis or preliminary preparation, for the program to be tested. Static analysis means to analyze a constant used to determine a data type match in a source code or byte code of a program. Also, dynamic analysis means analyzing a constant used to determine whether the data type of the character string matches when the program to be tested is being executed. For example, when there is a match determination of String type A.equals (B), constant B is added to String Pool by static analysis or dynamic analysis. Preparation means preparing in advance a string that may be used as an input value or a branch. For example, when an address is used as an input value, a string such as “Chiyoda-ku, Tokyo” is added to the String Pool in advance.
次に、テストケース生成装置は、生成された分岐結果に対して途中まで経路一致する目標分岐結果を生成し、目標分岐結果を満たすテストデータを生成する。この目標分岐結果を満たすテストデータの探索アルゴリズムとして、遺伝的アルゴリズムを用いる。遺伝的アルゴリズムは、テストデータの集合を遺伝子の集合として考え、遺伝子を選択、交叉及び突然変異によって操作することにより新たなテストデータを生成するものである。テストケース生成装置は、遺伝的アルゴリズムの突然変異において、String Poolから選択された文字列を用いて、新しいテストデータを生成する。このとき、String Poolの文字列の取得箇所を考慮することで、分岐との関連性の高い文字列を選択する。 Next, the test case generation device generates a target branch result that matches the path halfway to the generated branch result, and generates test data that satisfies the target branch result. A genetic algorithm is used as a search algorithm for test data that satisfies this target bifurcation result. The genetic algorithm considers a set of test data as a set of genes, and generates new test data by manipulating genes by selection, crossover and mutation. The test case generator generates new test data using a string selected from the String Pool in genetic algorithm mutation. At this time, by considering the string pool acquisition location of String Pool, select a string with high relevance to the branch.
ただし、結合テスト対象となる規模のソースコードに対し、Concolic TestingやSBSTを行うと計算爆発が起きるため、指定されたユーザ記述クラスを解析対象としてテストデータを生成してもよい。すなわち、フレームワークやライブラリ等のユーザが記述していない箇所に対しては、カバレッジを向上させるようなテストケースを生成しないことで、計算爆発を回避してもよい。 However, if concoric testing or SBST is performed on the source code of the size to be subjected to the binding test, a test explosion may occur, and test data may be generated with the specified user-descriptive class as an analysis target. That is, the calculation explosion may be avoided by not generating a test case that improves coverage for a portion such as a framework or a library that is not described.
最後に、テストケース生成装置は、テストシナリオ及びテストデータの組み合わせであるテストケースを出力する。 Finally, the test case generation apparatus outputs a test case that is a combination of a test scenario and test data.
<用語の説明>
まず、本発明の実施例において用いられる用語について説明する。
<Explanation of terms>
First, terms used in the embodiments of the present invention will be described.
テストスイートとは、複数のテストケースと、それぞれのテストケースを実行したときの分岐結果から構成される。本発明の実施例における最終的な出力となるテストケースとそのテストケースの分岐結果から構成されるテストスイートを出力テストスイートと呼び、SBSTを実行するために用いられるテストスイートを素材テストスイートと呼ぶ。例えば、テストスイートは、[テストケース1,分岐結果1],[テストケース2,分岐結果2],…として定義される。
The test suite is composed of a plurality of test cases and branching results when each test case is executed. A test suite consisting of a test case as a final output in the embodiment of the present invention and a branch result of the test case is called an output test suite, and a test suite used to execute SBST is a material test suite. . For example, a test suite is defined as [
テストケースとは、プログラムのテストを実行するために必要な情報を所持しているものであり、1つのテストシナリオと1つのテストデータから構成される。 A test case is one that possesses the information necessary to execute a program test, and is composed of one test scenario and one test data.
テストシナリオとは、テストを実行するための手順を表し、VCシナリオとView操作情報であるステップの集合から構成される。例えば、テストシナリオは、[VCシナリオ],[ステップ1,ステップ2,…]として定義される。
The test scenario represents a procedure for executing a test, and is composed of a set of steps that are VC scenario and View operation information. For example, a test scenario is defined as [VC scenario], [
テストデータとは、テストシナリオを実現するための具体的な値の集合である。SBSTにおいて、この具体的な値を求めるために遺伝的アルゴリズムが用いられる場合、テストデータは、遺伝子の集合と考えられる。便宜上、Concolic Testing等が用いられる場合であっても、テストデータを遺伝子の集合として定義する。例えば、テストデータは、遺伝子1,遺伝子2, …として定義される。
Test data is a set of specific values for realizing a test scenario. If a genetic algorithm is used to determine this specific value in SBST, then the test data is considered to be a collection of genes. For convenience, test data is defined as a set of genes, even if Concolic Testing etc. are used. For example, test data is defined as
Viewの遷移図とは、View間の繋がりを表した遷移図である。MVCに従って設計されたプログラムでは、ControllerはViewからの入力をModelに伝え、Modelの実行結果をViewに伝えるため、Controllerの情報を用いてView間の繋がりであるViewの遷移図が生成できる。 The view transition diagram is a transition diagram showing the connection between the views. In a program designed in accordance with MVC, since the Controller communicates the input from the View to the Model and the execution result of the Model to the View, the controller's information can be used to generate a transition diagram of the View, which is a connection between the Views.
VCシナリオとは、Viewの遷移図から生成されるView名及びController名の羅列である。VCシナリオは、View名で始まり、View名で終わる。例えば、VCシナリオは、View名→Controller名→View名→…→View名として定義される。 The VC scenario is a series of View names and Controller names generated from the View transition diagram. The VC scenario starts with the view name and ends with the view name. For example, a VC scenario is defined as View name → Controller name → View name →.
ステップとは、テストを実行するための手順であるテストシナリオの最小単位を表し、Webアプリケーションである場合には、htmlにおけるフォームやボタンに付与されるidと、動作を示すprocから構成される。 A step represents a minimum unit of a test scenario which is a procedure for executing a test, and in the case of a Web application, it is composed of an id given to a form or button in html and proc showing an operation.
遺伝子とは、テストデータの各要素を表し、Webアプリケーションである場合には、htmlにおけるフォームのidと、具体的な値であるvalueから構成される。 A gene represents each element of test data, and in the case of a Web application, it is composed of an id of a form in html and a value which is a specific value.
例えば、View1においてIDとPWを入力して、transmitというidが付与されている「ログイン」ボタンを押下するWebアプリケーションをテストする例を考える。この例では、1つのテストケースは、以下のテストシナリオとテストデータの組み合わせで構成される。
For example, consider an example of testing a web application in which an ID and a PW are input in
テストシナリオ:
VCシナリオ:View1→Controller1→…
ステップ1:id="ID", proc="入力"
ステップ2:id="PW", proc="入力"
ステップ3:id="transmit", proc="押下"
…
テストデータ:
遺伝子1:id="ID", value="aaaa"
遺伝子2:id="PW", value="1234"
…
すなわち、このテストケースは、(1)View1においてid="ID"となっているフォームに"aaaa"を入力し、(2)id="PW"となっているフォームに"1234"を入力し、(3)id="transmit"となっているボタンを押下することを意味する。
test scenario:
VC scenario:
Step 1: id = "ID", proc = "input"
Step 2: id = "PW", proc = "input"
Step 3: id = "transmit", proc = "press"
...
test data:
Gene 1: id = "ID", value = "aaaa"
Gene 2: id = "PW", value = "1234"
...
That is, in this test case, (1) enter "aaaa" in the form in which id = "ID" in
分岐結果は、テストケースを実行したときのコード上の各分岐の結果である分岐結果要素から構成される。例えば、分岐結果は、分岐結果要素1,分岐結果要素2,…として定義される。
The branch result is composed of branch result elements which are the result of each branch on the code when the test case is executed. For example, the branch result is defined as branch result
分岐結果要素は、判定分岐、判定順番、判定結果、及び評価値から構成される。判定分岐は、判定対象の分岐を示し、すなわち、どの分岐を判定したかを表す。判定順番は、判定分岐がプログラムの中の全分岐の中で何番目に判定されたかを表す。判定結果は、判定分岐の判定結果(True/False)を表す。評価値は、分岐の判定を定量的に表す値を表す。 The branch result element is composed of a judgment branch, a judgment order, a judgment result, and an evaluation value. The judgment branch indicates a branch to be judged, that is, which branch is judged. The determination order indicates the order in which the determination branch is determined among all the branches in the program. The determination result represents the determination result (True / False) of the determination branch. The evaluation value represents a value that quantitatively represents the determination of branching.
評価値について更に具体的に説明する。評価値は、分岐条件を満たしている度合い又は分岐条件を満たしていない度合いを表し、判定分岐に対して設定された評価関数によって取得できる。例えば、if(x>0)という分岐がある場合、x=1の場合とx=100の場合では同じTrueを返すが、x=100の時の方がx=1の時と比べて0より大きいため、より分岐条件を満たしている度合いは強いと評価することができる。分岐条件を満たしている場合には評価値は負の値を持ち、満たしていない場合には正の値を持つ。評価関数は、分岐に対して設定され、例えば、分岐条件がa==bである場合、評価関数はabs(a-b)として定義されてもよく、分岐条件がa!=bである場合、評価関数は-abs(a-b)として定義されてもよく、分岐条件がa<b又はa<=bである場合、評価関数はa-bとして定義されてもよく、分岐条件がa>b又はa>=bである場合、評価関数はb-aとして定義されてもよい。 The evaluation value will be described more specifically. The evaluation value represents the degree to which the branch condition is satisfied or the degree to which the branch condition is not satisfied, and can be acquired by the evaluation function set for the determination branch. For example, if there is a branch if (x> 0), the same True is returned in the case of x = 1 and in the case of x = 100, but it is more than 0 when x = 100 compared to when x = 1 Because the size is large, the degree of meeting the branching condition can be evaluated as being strong. The evaluation value has a negative value when the branch condition is satisfied, and has a positive value when the branch condition is not satisfied. The evaluation function is set for a branch, for example, if the branch condition is a == b, the evaluation function may be defined as abs (ab), if the branch condition is a! = B, evaluation The function may be defined as -abs (ab), and if the branching condition is a <b or a <= b, the evaluation function may be defined as ab, and the branching condition is a> b or a> = If b, the evaluation function may be defined as ba.
最終分岐結果要素とは、ある分岐結果の分岐結果要素のうち、判定順番の値が最も大きい値を持つ分岐結果要素を示す。また、最終分岐結果要素を除いた分岐結果の集合を途中分岐結果と定義する。最終分岐結果要素の判定分岐、判定順番、判定結果、及び評価値を、それぞれ最終判定分岐、最終判定順番、最終判定結果及び最終評価値と定義する。 The final branch result element indicates the branch result element having the largest value in the determination order among the branch result elements of a certain branch result. Also, a set of branch results excluding the final branch result element is defined as an intermediate branch result. The determination branch of the final branch result element, the determination order, the determination result, and the evaluation value are respectively defined as a final determination branch, a final determination order, a final determination result, and a final evaluation value.
図1に、分岐結果の例を示す。判定分岐が分岐a、分岐b、分岐cである3つの分岐結果要素から構成される分岐結果αを例に挙げると、最終分岐結果要素は分岐cの分岐結果要素である[c,3,True,-2]であり、途中分岐結果は、分岐a及び分岐bの分岐結果要素である[a,1,True,-1],[b,2,False,1]である。 FIG. 1 shows an example of the branching result. Taking a branch result α consisting of three branch result elements in which the judgment branch is branch a, branch b, and branch c as an example, the final branch result element is the branch result element of branch c [c, 3, True , -2], and the halfway branch result is [a, 1, True, -1], [b, 2, False, 1] which is the branch result elements of the branch a and the branch b.
経路一致とは、分岐結果Aと分岐結果Bが存在するとき、分岐結果Aの各分岐結果要素が全て、分岐結果Bの分岐結果要素のいずれかと、評価値を除いて一致している場合、分岐結果Aは分岐結果Bに対して経路一致していると定義する。 Path matching means that, when branch result A and branch result B exist, all the branch result elements of branch result A match any of the branch result elements of branch result B except for the evaluation value, Branch result A is defined as path match for branch result B.
図1に示す分岐結果α、分岐結果β、及び分岐結果γを例に挙げると、分岐結果αの分岐結果要素は、分岐結果βの分岐結果要素のいずれかと、評価値を除いて一致しているため、分岐結果αは分岐結果βに対して経路一致している。また、分岐結果αの分岐結果要素は、分岐結果γのいずれかと、評価値を除いて一致していないため、分岐結果αは分岐結果γに対して経路一致していない。 Taking the branch result α, the branch result β, and the branch result γ shown in FIG. 1 as an example, the branch result elements of the branch result α coincide with any of the branch result elements of the branch result β except for the evaluation value Therefore, the branch result α matches the path with respect to the branch result β. Further, since the branch result element of the branch result α does not match any of the branch results γ except for the evaluation value, the branch result α does not match the path with the branch result γ.
String Poolとは、遺伝的アルゴリズムの突然変異においてテストデータの生成に用いられる文字列の集合である。遺伝的アルゴリズムの突然変異では、定数をランダムに生成する必要があるが、String Poolに予め分岐を解くために有益であると考えられる定数を記憶しておくことで、突然変異においてString Poolに存在する定数を利用し、String型を含む条件分岐に対して網羅性を向上させることができる。例えば、String Poolは、Pool要素1,Pool要素2…として定義される。
String Pool is a set of strings used to generate test data in genetic algorithm mutation. In genetic algorithm mutation, it is necessary to generate a constant at random, but it exists in String Pool by storing constant considered to be useful for solving branch in String Pool beforehand. Can be used to improve the completeness for conditional branches including the String type. For example, String Pool is defined as
Pool要素とは、String Poolに記憶されている要素であり、定数及び出典から構成される。 The Pool element is an element stored in String Pool, and is composed of a constant and a source.
定数とは、静的解析、動的解析又は事前準備によって取得した値を記憶する要素である。 A constant is an element that stores values acquired by static analysis, dynamic analysis, or preparation.
出典とは、定数を取得した箇所を示す要素である。静的解析又は動的解析では定数はソースコード又はバイトコードから取得されるため、例えば、「クラス名#メソッド名#行数」で出典を表す。定数が事前準備によって取得している場合、出典は「事前準備」とする。 The source is an element indicating the place where the constant is obtained. In static analysis or dynamic analysis, a constant is obtained from a source code or byte code, so for example, "class name # method name # number of lines" represents a source. If the constant has been acquired by preparation, the source will be "prepare".
カバレッジとは、プログラムのソースコードがテストされた割合を示す。単位は%である。カバレッジの基準は複数存在し、例えば、分岐網羅率及び条件網羅率が存在するが、特に明記しない限り、本発明の実施例では分岐網羅率をカバレッジと呼ぶ。カバレッジの高いテストデータの集合のことを網羅的なテストデータ又は網羅性の高いテストデータと呼ぶ。 The coverage indicates the rate at which the program source code was tested. The unit is%. There are a plurality of coverage criteria, for example, branch coverage and condition coverage exist, but in the embodiment of the present invention, branch coverage is called coverage, unless otherwise specified. A set of test data with high coverage is called exhaustive test data or highly comprehensive test data.
図2に、分岐網羅率と条件網羅率との関係を示す。分岐網羅率は、C1カバレッジとも呼ばれ、プログラム内の分岐がテストされた割合を示す。例えば、図2のような2つの分岐A及び分岐Bが存在するプログラムにおいてC1カバレッジを100%とするためには、分岐A=False且つ分岐B=Trueの場合と、分岐A=True且つ分岐B=Falseの場合の2つをテストする必要がある。 FIG. 2 shows the relationship between the branch coverage rate and the condition coverage rate. Branch coverage is also called C1 coverage and indicates the percentage of branches tested in the program. For example, in a program having two branches A and B as shown in FIG. 2, in order to set C1 coverage to 100%, the case of branch A = False and branch B = True, branch A = True and branch B We need to test two things in the case of = False.
また、条件網羅率は、C2カバレッジとも呼ばれ、プログラム内の条件がテストされた割合を示す。例えば、図2のような2つの分岐A及び分岐Bが存在するプログラムにおいてC2カバレッジを100%とするためには、分岐A=False且つ分岐B=Trueの場合と、分岐A=True且つ分岐B=Falseの場合と、分岐A=True且つ分岐B=Trueの場合と、分岐A=False且つ分岐B=Falseの場合の4つをテストする必要がある。 Condition coverage is also called C2 coverage, and indicates the rate at which conditions in the program were tested. For example, in order to set C2 coverage to 100% in a program having two branches A and B as shown in FIG. 2, branch A = False and branch B = True, branch A = True and branch B. It is necessary to test four cases: = False, branch A = True and branch B = True, and branch A = False and branch B = False.
<テストケース生成装置の構成>
次に、本発明の実施例に係るテストケース生成装置の構成について説明する。図3は、本発明の実施例に係るテストケース生成装置100の機能ブロック図である。
<Configuration of Test Case Generation Device>
Next, the configuration of a test case generation apparatus according to an embodiment of the present invention will be described. FIG. 3 is a functional block diagram of a test
テストケース生成装置100は、CPU(Central Processing Unit)等のプロセッサ、RAM(Random Access Memory)やROM(Read Only Memory)等のメモリ装置、ハードディスク等の記憶装置等から構成されたコンピュータでもよい。例えば、テストケース生成装置の機能及び処理は、記憶装置又はメモリ装置に格納されているデータやプログラムをプロセッサが実行することによって実現されてもよい。
The test
テストケース生成装置100は、ソースコードを入力とし、テストシナリオ及びテストデータの組み合わせであるテストケースを出力する。
The test
テストケース生成装置100は、VCシナリオ生成部101と、テストシナリオ生成部103と、テストデータ生成部105とを有する。なお、本発明の実施例は、VCシナリオ生成部101及びテストシナリオ生成部103を含まず、テストデータ生成部105を含むテストデータ生成装置として実現されてもよい。例えば、処理フロー図等から生成されたテストシナリオが指定され、テストデータ生成装置が指定のテストシナリオに対するテストデータを生成してもよい。
The test
VCシナリオ生成部101は、MVCに従って設計されたアプリケーションのプログラムをテスト対象としたときに、ソースコード内のControllerの情報を用いてViewの遷移図を生成する。図4の左側にViewの遷移図の例を示す。遷移図は、状態と、状態同士の関連性を表す線である遷移で構成される。ソースコードにおけるViewは1つの状態と考えられ、Controllerも1つの状態と考えられる。ControllerはViewからの入力をModelに伝え、Modelの実行結果をViewに伝えるため、Controllerの情報を用いてView間の繋がりであるViewの遷移図が抽出できる。更に、VCシナリオ生成部101は、Viewの遷移図から状態遷移図に対する所定のカバレッジ基準に基づいてView及びControllerの繋がりを表すVCシナリオを生成する。図4の左側に示すように、Controller1、Controller2、Controller3によってView1、View2、View3の繋がりであるViewの遷移図が生成できると、図4の右側に示すように、1つのView名から始まり1つのView名で終わる複数のVCシナリオが生成できる。VCシナリオの数は状態の数によって膨大な数となるため、状態遷移図に対する所定のカバレッジ基準に基づいてVCシナリオを生成する。
The VC
図5は、状態遷移図に対するカバレッジ基準を示す図である。例えば、状態遷移図に対する所定のカバレッジ基準として、All-states、All-transitions、All-transition-pairs、All-loop-free-paths、All-one-loop-paths、All-paths等が存在する。All-statesとは、全状態がどこかのシナリオに含まれるという基準である。例えば、図5に示す状態遷移図を例に挙げると、状態A→状態B→状態D→状態E→状態B→状態Cのシナリオは、All-statesを満たす。All-transitionsとは、全ての長さが1以下のシナリオ(1遷移)がカバーされるという基準である。例えば、図5に示す状態遷移図を例に挙げると、状態A→状態B、状態B→状態C、状態B→状態D、状態D→状態E、状態E→状態Bのシナリオは、All-transitionsを満たす。All-transition-pairsとは、全ての長さが2以下のパス(遷移ペア)がカバーされるという基準である。例えば、図5に示す状態遷移図を例に挙げると、All-transitionsを満たすシナリオに加えて、状態A→状態B→状態C、状態A→状態B→状態D、状態B→状態D→状態E、状態D→状態E→状態B、状態E→状態B→状態D、状態E→状態B→状態Cのシナリオは、All-transition-pairsを満たす。All-loop-free-pathsとは、同じ状態が2回以上現れず、且つ、他のシナリオに部分的に含まれないようなシナリオ(prime pathと呼ばれる)が全てカバーされるという基準である。なお、All-loop-free-pathsはAll-transitionsを保証するものではない。例えば、図5に示す状態遷移図を例に挙げると、状態A→状態B→状態C、状態A→状態B→状態D→状態Eのシナリオは、All-loop-free-pathsを満たす。All-one-loop-pathsとは、All-loop-free-pathsに加えて、ループ1つのみを1回だけ回るシナリオがカバーされるという基準である。例えば、図5に示す状態遷移図を例に挙げると、状態A→状態B→状態C、状態A→状態B→状態D→状態E→状態B→状態Cのシナリオは、All-one-loop-pathsを満たす。All-pathsとは、全てのシナリオがカバーされるという基準である。なお、通常はループが存在するため、All-pathsを満たすシナリオは無限通り存在するため、有用ではない。 FIG. 5 is a diagram showing coverage criteria for the state transition diagram. For example, All-states, All-transitions, All-transition-pairs, All-loop-free-paths, All-one-loop-paths, All-paths etc. exist as predetermined coverage criteria for the state transition diagram. All-states is a criterion that all states are included in some scenario. For example, taking the state transition diagram shown in FIG. 5 as an example, the scenario of state A → state B → state D → state E → state B → state C satisfies All-states. All-transitions is a criterion that scenarios of which all lengths are 1 or less (1 transition) are covered. For example, taking the state transition diagram shown in FIG. 5 as an example, the scenarios of state A → state B, state B → state C, state B → state D, state D → state E, and state E → state B are All- Meet the transitions. All-transition-pairs is a criterion that paths (transition pairs) with all lengths of 2 or less are covered. For example, taking the state transition diagram shown in FIG. 5 as an example, in addition to the scenario satisfying All-transitions, state A → state B → state C, state A → state B → state D, state B → state D → state The scenario of E, state D → state E → state B, state E → state B → state D, state E → state B → state C satisfies All-transition-pairs. The All-loop-free-paths is a criterion that all scenarios (referred to as prime paths) in which the same state does not appear twice or more and which is not partially included in other scenarios are covered. Note that All-loop-free-paths does not guarantee All-transitions. For example, taking the state transition diagram shown in FIG. 5 as an example, the scenario of state A → state B → state C, state A → state B → state D → state E satisfies All-loop-free-paths. All-one-loop-paths is a criterion that, in addition to All-loop-free-paths, a scenario in which only one loop travels only once is covered. For example, taking the state transition diagram shown in FIG. 5 as an example, the scenario of state A → state B → state C, state A → state B → state D → state E → state B → state C is All-one-loop Meet -paths. All-paths is a criterion that all scenarios are covered. Note that since there is usually a loop, there is no limit to the scenario that satisfies All-paths, so it is not useful.
テストシナリオ生成部103は、生成されたVCシナリオにView操作情報を追加する。例えば、クローラやユーザ操作等によって、生成されたVCシナリオを満たすようなView操作情報を追加する。View操作情報は、ステップの集合で表される。具体的には、クローラやユーザ操作等によってテスト対象のプログラムを動かすことで、テストシナリオ生成部103は、生成されたVCシナリオと同じ遷移をするView操作情報を取得すると共に、View操作情報を取得したときのテストデータである初期テストデータを取得する。テストシナリオ生成部103は、VCシナリオにView操作情報及び初期テストデータを追加した初期テストケースを生成する。
The test
テストデータ生成部105は、生成されたテストシナリオのうち1つのシナリオを指定してテストデータを生成する。ここでは、最初にConcolic Testingによってテストデータ及び分岐結果を生成し、Concolic Testingによって得られたテストデータ及び分岐結果を用いてSBSTによって新たなテストデータを生成する構成例について説明するが、最初にテストデータ及び分岐結果を生成するためのテストデータ生成手法はConcolic Testingに限定されない。Concolic TestingとSBSTとの組み合わせが用いられる場合、テストデータ生成部105は、コード挿入部111と、Concolic Testing部113と、SBST部115とを有する。
The test
コード挿入部111は、テスト対象のプログラムに、分岐の判定を定量的に評価するための評価値を含む分岐結果を出力するコードを挿入する。このように、コード挿入部111は、Concolic Testingを実行している間にSBSTで必要な情報を予め取得するためのコードを挿入する。コード挿入部111は、解析対象のユーザ記述クラス内における分岐の箇所に、分岐結果を出力するコードを挿入してもよい。コード挿入部111は、解析対象のユーザ記述クラスに対しては、プログラムの分岐を解析するためのコードを挿入してもよいが、フレームワークやライブラリ等のユーザが記述していない箇所は解析対象外とし、プログラムの分岐を解析するためのコードを挿入しなくてもよい。
The
また、コード挿入部111は、テスト対象のプログラムの文字列のデータ型の一致判定の箇所に、Pool要素を出力するコードを挿入する。このように、コード挿入部111は、SBSTを実行している間に動的解析によって文字列を取得するためのコードを挿入する。
In addition, the
Concolic Testing部113は、入力値を記号に置き換えて得られた制約式を解析することによりテストデータを生成すると共に、挿入されたコードが出力した分岐結果を生成する。このように、Concolic Testing部113は、テストデータを生成している間に、SBSTで必要な情報である分岐結果を収集する。すなわち、Concolic Testing部113は、指定のテストシナリオに対してテストデータを生成する過程において、指定のテストシナリオと当該テストデータと分岐結果とを、SBSTを実行するために用いられる素材テストスイートに追加する。素材テストスイートには、経路一致している分岐結果が存在する可能性があるため、Concolic Testing部113は、指定のテストシナリオに対して生成されたテストデータによってカバレッジが向上する場合、指定のテストシナリオと当該テストデータと分岐結果とを出力テストスイートに追加する。
The
SBST部115は、テストデータを生成するために遺伝的アルゴリズムを用いる。遺伝的アルゴリズムの選択、交叉、及び突然変異をそれぞれ実施するため、SBST部115は、選択部121と、交叉部123と、突然変異部125とを含む。特に、突然変異部125は、テスト対象のプログラムに対して、静的解析、動的解析又は事前準備によって、テストデータの生成に用いられる文字列の集合であるString Poolを取得するString Pool部131を含む。突然変異部125は、突然変異において、String Pool部131におけるString Poolから選択された文字列を用いて、新しいテストデータを生成する。具体的には、SBST部115は、Concolic Testing部113において生成された分岐結果に対して途中まで経路一致する目標分岐結果を生成し、突然変異部125において、String Poolから選択された文字列を用いて、目標分岐結果を満たすテストデータを生成する。
The
このようにして、SBST部115は、出力テストスイートの分岐結果に対して途中まで経路一致する目標分岐結果を生成し、目標分岐結果と経路一致するテストデータが出力テストスイートに存在しない場合、素材テストスイートを用いて目標分岐結果を満たすテストデータを生成し、出力テストスイートに追加する。更に、SBST部115のString Pool部131は、目標分岐結果を満たすテストデータを生成する過程において、コード挿入部111において挿入されたコードが出力したPool要素を取得する。
In this manner, the
また、SBST部115の突然変異部125は、String Pool部131において取得された文字列の取得箇所を考慮することで、分岐との関連性の高い文字列を選択する。String Pool部131のPool要素には文字列を取得した箇所を示す出典も記憶されている。String Pool部131の文字列は、出典によって、(1)動的解析又は静的解析によって目標分岐結果の最終判定分岐が属するクラス及びメソッドから生成された第1の文字列、(2)動的解析又は静的解析によって目標分岐結果の最終判定分岐が属するクラスから生成されたが異なるメソッドから生成された第2の文字列、(3)動的解析又は静的解析によって目標分岐結果の最終判定分岐が属さないクラスから生成された第3の文字列、(4)事前準備によって生成された第4の文字列に分類される。この場合、(1)第1の文字列、(2)第2の文字列、(3)第3の文字列、(4)第4の文字列の順に分岐との関連性が高いと考えられる。従って、突然変異部125は、第1の文字列が選択される確率を第2の文字列が選択される確率より高く設定し、第2の文字列が選択される確率を第3の文字列が選択される確率より高く設定し、第3の文字列が選択される確率を第4の文字列が選択される確率より高く設定する。
In addition, the
<テストケース生成方法の手順>
次に、本発明の実施例に係るテストケース生成方法について説明する。図6は、本発明の実施例に係るテストケース生成方法のフローチャートである。
<Procedure of test case generation method>
Next, a test case generation method according to an embodiment of the present invention will be described. FIG. 6 is a flowchart of a test case generation method according to an embodiment of the present invention.
まず、ステップS001において、VCシナリオ生成部101は、テスト対象のプログラムのソースコードを入力として受け取り、ソースコード内のControllerの情報を用いて、View間の繋がりを表すViewの遷移図を生成する。
First, in step S001, the VC
ステップS001について図7を参照して更に説明する。 Step S001 will be further described with reference to FIG.
ステップS101において、VCシナリオ生成部101は、テスト対象のプログラムのソースコードを入力として受け取り、ソースコード内のViewを抽出する。
In step S101, the VC
ステップS102において、VCシナリオ生成部101は、テスト対象のプログラムのソースコードを入力として受け取り、Controllerの情報を用いてView間の繋がりを検出する。具体的には、VCシナリオ生成部101は、抽出されたViewの1つを対象Viewとして選択し、対象View名で指定されたViewの遷移先のControllerを取得する。そして、取得した遷移先のControllerの遷移先のViewを対象Viewの遷移先のViewとする。ステップS101で抽出した各Viewに上記の処理を繰り返すことで、各対象Viewの全ての遷移先のView名と、これらの間に存在するController名が出力される。
In step S102, the VC
ステップS103において、VCシナリオ生成部101は、各対象Viewの全ての遷移先のView名と、これらの間に存在するController名を入力として受け取り、Viewの遷移図を作成する。Viewの遷移図には、View名だけでなく、Controller名も記録される。Viewの遷移図が生成された場合、図6のステップS002に戻る。
In step S103, the VC
次に、図6のステップS002において、VCシナリオ生成部101は、Viewの遷移図を入力として受け取り、Viewの遷移図に対して、状態遷移図に対する所定のカバレッジ基準に基づいてVCシナリオを生成する。
Next, in step S002 of FIG. 6, the VC
ステップS002について図8を参照して更に説明する。 Step S002 will be further described with reference to FIG.
ステップS104において、VCシナリオ生成部101は、Viewの遷移図を状態遷移図として扱い、All-states等の状態遷移図に対する所定のカバレッジ基準に基づいて、複数のVCシナリオを作成する。VCシナリオが生成された場合、図6のステップS003に戻る。
In step S104, the VC
次に、図6のステップS003において、テストシナリオ生成部103は、VCシナリオを入力として受け取り、各VCシナリオに対してVCシナリオを満たすテストケースを、クローラ等の技術を用いて生成する。そして、VCシナリオを実現するテストシナリオ及びテストデータを1件のテストケース(初期テストケース)として出力する。
Next, in step S003 in FIG. 6, the test
ステップS003について図9を参照して更に説明する。 Step S003 will be further described with reference to FIG.
ステップS105において、テストシナリオ生成部103は、テスト対象のプログラムとVCシナリオを入力として受け取り、クローラ等によってテスト対象のプログラムを実際に操作し、VCシナリオの先頭のViewが表すhtmlファイルにアクセスするURLに移動する。なお、テスト対象のプログラムの操作は、クローラ等の他にユーザによる操作でも代用可能である。
In step S105, the test
ステップS106において、テストシナリオ生成部103は、空のテストケースTC0を作成する。空のテストケースTC0には、テストシナリオであるVCシナリオとステップの集合の具体的な値は入っておらず、テストデータも入っていない。
In step S106, the test
ステップS107において、テストシナリオ生成部103は、テスト対象のプログラムとテストケースTC0を入力として受け取り、クローラ等によってテスト対象のプログラムを実際に操作し、テスト対象のプログラムを操作したときに入力したフォームのidやその値をテストケースTC0のテストデータに追加し、入力したフォームのidや押下したボタンのid等をテストケースTC0のテストシナリオに追加する。なお、テスト対象のプログラムの操作は、クローラ等の他にユーザによる操作でも代用可能である。また、操作中のViewやControllerの遷移も取得し、テストケースTC0のテストシナリオに追加する。新しいViewに遷移したところで次のステップS108に移行する。
In step S107, the test
ステップS108において、テストシナリオ生成部103は、テストケースTC0とVCシナリオを入力として受け取り、VCシナリオのView及びControllerの遷移と、テストケースTC0が途中又は最後まで同じ遷移をしているか否かを判断する。同じ遷移をしていない場合、ステップS109に移行し、同じ遷移をしている場合、ステップS110に移行する。
In step S108, the test
ステップS109において、テストシナリオ生成部103は、テストケースTC0を入力として受け取り、VCシナリオの遷移とテストケースTC0の遷移が異なる場合、テストケースTC0はVCシナリオを満たさないため、テストケースTC0を破棄し、ステップS105に移行する。
In step S109, test
ステップS110において、テストシナリオ生成部103は、テストケースTC0とVCシナリオを入力として受け取り、VCシナリオのView及びControllerの遷移と、テストケースTC0が最後まで同じ遷移をしているか否かを判断する。最後まで同じ遷移をしていない場合、すなわち、途中までは同じ遷移をしているが、最後まで同じ遷移をしていない場合には、更にテスト対象のプログラムを操作する必要があるため、ステップS107に移行する。同じ遷移をしている場合、ステップS111に移行する。
In step S110, the test
ステップS111において、テストシナリオ生成部103は、テストケースTC0を入力として受け取り、テストケースTC0を初期テストケースとして出力する。初期テストケースが出力された場合、図6のステップS004に戻る。
In step S111, the test
次に、図6のステップS004において、テストデータ生成部105のString Pool部131は、事前準備したコンスタントを入力として受け取り、String Poolを作成し、事前準備したコンスタントをString Poolに追加する。このときの出典は「事前準備」とする。
Next, in step S 004 of FIG. 6, the
ステップS004について図10を参照して更に説明する。 Step S 004 will be further described with reference to FIG.
ステップS701において、String Pool部131は、事前準備したコンスタントを入力として受け取り、各コンスタントに対して、定数をコンスタントの値とし、出典を事前準備としたPool要素をString Poolに追加する。事前準備によってPool要素がString Poolに追加された場合、図6のステップS005に戻る。
In step S701, the
次に、図6のステップS005において、テストデータ生成部105のコード挿入部111は、テスト対象のプログラムのバイトコードを入力として受け取り、ユーザ記述クラス内のメソッド上のバイトコードに対して、テストデータ生成に必要な情報を取得するためのコードを挿入する。なお、バイトコードの代わりにソースコードを入力として受け取ってもよい。Concolic Testingでは、入力値を記号に置き換えて得られた制約式を解析する必要があるため、入力値を記号に置き換えるためのコードを挿入する。また、コード挿入部111は、Concolic Testingを実行している間にSBSTで必要な情報を予め取得するためのコードを挿入する。SBSTでは、分岐の評価値を解析する必要があるため、分岐に対する評価関数の値を出力するためのコードを挿入する。コード挿入部111は、ユーザ記述クラスにコード挿入されたバイトコードを出力する。更に、コード挿入部111は、SBSTを実行している間に動的解析によってPool要素を取得するためのコードを挿入する。
Next, in step S005 in FIG. 6, the
なお、コード挿入部111は、解析対象のユーザ記述クラス名を入力として受け取ってもよく、解析対象外のユーザ記述クラス名を入力として受け取ってもよい。解析対象のユーザ記述クラス名及び解析対象外のユーザ記述クラス名は、ネームスペースで指定されてもよい。この場合、コード挿入部111は、解析対象のユーザ記述クラス内のメソッド上のバイトコードに対して、テストデータ生成に必要な情報を取得するためのコードを挿入する。
The
ステップS005について図11を参照して更に説明する。 Step S005 will be further described with reference to FIG.
ステップS112において、コード挿入部111は、ユーザにより入力された解析対象のユーザ記述クラス名を入力として受け取ってもよい。また、コード挿入部111は、ユーザにより入力された解析対象外のユーザ記述クラス名を入力として受け取ってもよい。ユーザ記述クラス名がネームスペースで指定された場合、コード挿入部111は、指定されたネームスペースを持つクラスの名前をバイトコードを調べて取得する。ただし、解析対象外のユーザクラス名が存在する場合、コード挿入部111は、解析対象外のユーザクラス名を持つユーザ記述クラスを除外する。
In step S112, the
ステップS113において、コード挿入部111は、解析対象のユーザ記述クラス内のフィールド及びメソッド上のバイトコードの各行を調べ、テストデータ生成に必要な情報を取得するためのコードを挿入する。コード挿入部111は、Concolic Testingで必要な情報を取得するために、解析対象のユーザ記述クラス内における入力値に対する演算が施される行及び分岐の行に、入力値を記号に置き換えるためのコードを挿入する。また、コード挿入部111は、SBSTで必要な情報を取得するために、解析対象のユーザ記述クラス内における分岐の箇所に、分岐結果を出力するコードを挿入する。ユーザ記述クラス内のメソッド上でコードを挿入する必要がない行に対しては何も実施しない。
In step S113, the
ステップS114において、テストデータ生成部105のString Pool部131は、解析対象のユーザ記述クラス内のフィールド及びメソッド上のバイトコードの各行に対して静的解析を行い、得られたオペランドやコンスタントをString Poolに追加する。このときの出典は、オペランドやコンスタントを取得した箇所である「クラス名#メソッド名#行数」とする。
In step S114, the
ステップS115において、コード挿入部111は、解析対象のユーザ記述クラス内のフィールド及びメソッド上のバイトコードの各行を調べ、String型の一致判定が存在するか否かを判断する。String型の一致判定とは、例えばA.equals(B)という文字列同士を比較する箇所を示す。String型の一致判定が存在しない場合、次の行を調べ、String型の一致判定が存在する場合、ステップS116に移行する。
In step S115, the
ステップS116において、コード挿入部111は、テスト対象のプログラムを実際に操作したときに、文字の比較対象のオペランド(例えば、A.equals(B)の場合のB)と、出典をString Poolに追加できるようなコードを挿入する。このときの出典は、オペランドを取得した箇所である「クラス名#メソッド名#行数」とする。例えば、hogeクラスのfugaメソッド内の10行目がA.equals(B)である場合、コード挿入部111は、「定数:B,出典:hoge#fuga#10」となるPool要素をString Poolに追加できるように、コード挿入を実施する。ユーザ記述クラス内のフィールド及びメソッド上でコードを挿入する必要がない行に対しては何も実施しない。コードが挿入された場合、図6のステップS006に戻る。
In step S116, when the program to be tested is actually operated, the
次に、初期テストケースの中から1つのテストケースを指定し、以下のようにテストデータを生成する。 Next, one test case is specified from the initial test cases, and test data is generated as follows.
図6のステップS006において、テストデータ生成部105のConcolic Testing部113は、空の出力テストスイートを作成する。空の出力テストスイートには、テストシナリオであるVCシナリオとステップの集合の具体的な値は入っておらず、テストデータも分岐結果も入っていない。
In step S006 in FIG. 6, the
次に、図6のステップS007において、Concolic Testing部113は、コード挿入されたバイトコードと、初期テストケースと、出力テストスイートを入力として受け取り、初期テストケースに基づき、Concolic Testingに従ってテストデータを生成し、得られたテストケースを出力テストスイートに追加する。
Next, in step S 007 in FIG. 6, the
ステップS007について図12を参照して更に説明する。 Step S007 will be further described with reference to FIG.
ステップS114において、Concolic Testing部113は、初期テストケースを入力として受け取り、初期テストケースを複製してテストケースTCNと定義する。
In step S114, the
ステップS115において、Concolic Testing部113は、テストケースTCN及びコード挿入されたバイトコードを入力として受け取り、Concolic Testingに従って新しいテストデータを生成する。Concolic Testingでは、テストケースTCNを実際に実行する必要があるが、テストケースTCNにはView操作情報を含むテストシナリオや、具体的なテストデータが含まれているため、スクリプトを作成し、スクリプトを実行するツールであるSelenium等を利用することにより自動的にConcolic Testingを実行することができる。また、コード挿入部111によってSBSTで必要な情報である分岐結果を出力するコードが挿入されているため、Concolic Testing部113は、テストデータと共に分岐結果を取得することができる。
In step S115, the
ステップS116において、Concolic Testing部113は、生成したテストデータと初期テストケースを入力として受け取り、生成したテストデータを初期テストケースの中のテストデータと置き換えて、新しいテストケースTCNを出力する。
In step S116, the
ステップS117において、Concolic Testing部113は、テストケースTCNと分岐結果と素材テストスイートを入力として受け取り、テストケースTCNと分岐結果を素材テストスイートに追加する。
In step S117, the
ステップS118において、Concolic Testing部113は、テストケースTCNと出力テストスイートを入力として受け取り、テストケースTCNを出力テストスイートに加えることでカバレッジが向上するか否かを判断する。カバレッジが向上する場合、ステップS119に移行し、カバレッジが向上しない場合、ステップS120に移行する。
In step S118, the
ステップS119において、Concolic Testing部113は、テストケースTCNと分岐結果と出力テストケースを入力として受け取り、テストケースTCNと分岐結果を出力テストスイートに追加する。
In step S119, the
ステップS120において、Concolic Testing部113は、解析が終わっていない場合、ステップS115に移行し、テストデータの生成を繰り返す。解析が終わった場合、図6のステップS008に戻る。
In step S120, if the analysis has not been completed, the
次に、図6のステップS008において、テストデータ生成部105のSBST部115は、SBSTで必要な情報である分岐結果を出力するコードが挿入されたバイトコードと出力テストスイートと素材テストスイートを入力として受け取る。SBST部115は、コードが挿入されたバイトコードに対し、テストデータの各遺伝子を入力としてテスト対象のプログラムを実際に動かして解析するSBSTを実行し、Concolic Testing部113で生成したテストデータが通過することのできない分岐を通過するようなテストデータを生成する。SBST部115は、このようにカバレッジを向上させるテストデータを出力テストスイートに追加して出力テストスイートを強化する。なお、SBST部115で用いるテストデータは、素材テストスイートから選択される。
Next, in step S008 in FIG. 6, the
ステップS008について図13を参照して更に説明する。 Step S008 will be further described with reference to FIG.
ステップS201において、SBST部115は、出力テストスイートの各分岐結果BR0に対して、分岐結果BR0の分岐結果要素の数をnとする。
In step S201, the
ステップS202において、SBST部115は、分岐結果BR0を入力として受け取り、分岐結果BR0に対し、判定順番の値がnより大きい分岐結果要素を全て削除した新しい分岐結果BRを作成する。
In step S202, the
ステップS203において、SBST部115は、分岐結果BRを入力として受け取り、分岐結果BRに対し、最終判定結果を反転した新しい分岐結果を作成し、目標分岐結果とする。例えば、分岐結果BRの最終判定結果がTrueである場合、その最終判定結果をFalseとし、分岐結果BRの最終判定結果がFalseである場合、その最終判定結果をTrueとする。
In step S203, the
ステップS204において、SBST部115は、目標分岐結果と経路一致する分岐結果が出力テストスイートに存在するか否かを判断する。図1を参照して説明した通り、ここでは分岐結果の経路一致を判断するため、評価値は異なってもよい。目標分岐結果と経路一致する分岐結果が出力テストスイートに存在しない場合、ステップS205に移行し、存在する場合、ステップS206に移行する。
In step S204, the
ステップS205において、SBST部115は、素材テストスイートと目標分岐結果を入力として受け取り、目標分岐結果を満たすようなテストデータをSBSTによって生成する。
In step S205, the
ステップS205について、図14を参照して更に説明する。 Step S205 will be further described with reference to FIG.
ステップS301において、遺伝的アルゴリズムを用いてSBSTを実行するときの最大世代数をGとし、現在の世代gを1とする。 In step S301, a maximum generation number when executing SBST using a genetic algorithm is G, and a current generation g is 1.
ステップS302において、SBST部115は、素材テストスイートと目標分岐結果を入力として受け取り、素材テストスイートの各分岐結果に対し、目標分岐結果の最終判定分岐を持つ分岐結果要素の評価値でソートする。例えば、目標分岐結果の最終判定分岐がTrueである場合、評価値の値が小さいほど優秀であると判断し、目標分岐結果の最終判定分岐がFalseである場合、評価値の値が大きいほど優秀であると判断する。ただし、目標分岐結果の最終判定分岐を持たない分岐結果は、最も優秀でないと判断する。SBST部115は、優秀であると判断された分岐結果と、それに対応するテストケースを上から順番に並べてソートする。
In step S302, the
ステップS303において、SBST部115は、空のテストスイートTSを生成する。空のテストスイートTSには、テストケースの具体的な値は入っておらず、分岐結果も入っていない。
In step S303, the
ステップS304において、SBST部115の選択部121は、ソートされた素材テストスイートとテストスイートTSとを入力として受け取り、ソートされた素材テストスイートの上から順番に複数のテストケースを選択する。選択されるテストケースの個数は、予め決められた定数とする。選択部121は、選択されたテストケースの遺伝子を操作したテストケースを生成する。例えば、選択部121は、選択されたテストケースが持つ1つの遺伝子に対し、int型であればランダムで1を加えてもよく、1を引いてもよい。例えば、選択部121は、選択されたテストケースが持つ1つの遺伝子に対し、String型であればランダムで1文字を追加してもよく、1文字を削除してもよい。選択部121は、この動作を全ての遺伝子に対して実施することで、1つのテストケースに対し、遺伝子の数だけ新しいテストケースを生成し、新しいテストケースをテストスイートTSに追加する。
In step S304, the
ステップS305において、SBST部115の交叉部123は、ソートされた素材テストスイートとテストスイートTSとを入力として受け取り、ソートされた素材テストスイートの上から順番に複数のテストケースを選択する。選択されるテストケースの個数は、予め決められた定数とする。交叉部123は、選択されたテストケースの遺伝子を配合した新しいテストケースを生成する。例えば、交叉部123は、選択されたテストケースの中から2つのテストケースを無作為に抽出し、2つのテストケースが持つ遺伝子をそれぞれランダムに配合した新しいテストケースを生成する。交叉部123は、この動作を繰り返すことで、予め決められた一定数の新しいテストケースを生成し、新しいテストケースをテストスイートTSに追加する。
In step S305, the
ステップS305について、図14を参照して更に説明する。 Step S305 will be further described with reference to FIG.
ステップS401において、交叉部123は、ソートされた素材テストスイートを入力として受け取り、ソートされた素材テストスイートの上から順番に複数のテストケースを抽出する。
In step S401, the
ステップS402において、交叉部123は、抽出したテストケース群を入力として受け取り、テストケース群から2つのテストケースを無作為に抽出し、それぞれの遺伝子を無作為に配合した新しいテストケースを生成する。例えば、交叉部123は、テストケース群からテストケースA及びテストケースBを抽出する。ここで、テストケースA及びテストケースBのテストシナリオは同じであるため、テストケースA及びテストケースBは同じidを持つ遺伝子をそれぞれ所有している。交叉部123は、id毎に遺伝子をテストケースA及びテストケースBから無作為に抽出することで新しいテストケースを作成する。例えば、テストケースAの遺伝子が[[id=1,value=0],[id=2,value=1]]であり、テストケースBの遺伝子が[[id=1,value=10],[id=2,value=5]]であるとすると、[[id=1,value=0],[id=2,value=1]],[[id=1,value=0],[id=2,value=5]],[[id=1,value=10],[id=2,value=1]],[[id=1,value=10],[id=2,value=5]]の4通りのテストケースが生成され得る。
In step S402, the
ステップS403において、交叉部123は、作成したテストケースとテストスイートTSを入力として受け取り、作成したテストケースをテストスイートTSに追加する。
In step S403, the
ステップS404において、交叉部123は、予め決められた一定数の新しいテストケースを作成したか否かを判断し、作成していない場合、ステップS402に戻り、上記の処理を繰り返す。一定数の新しいテストケースを作成した場合、図14のステップS306に戻る。
In step S404, the
次に、図14のステップS306において、SBST部115の突然変異部125は、ソートされた素材テストスイートとテストスイートTSとを入力として受け取り、ソートされた素材テストスイートの上から順番に複数のテストケースを選択する。選択されるテストケースの個数は、予め決められた定数とする。突然変異部125は、選択されたテストケースの遺伝子を突然変異した新しいテストケースを生成する。例えば、突然変異部125は、選択されたテストケースが持つ1つの遺伝子に対し、一定の確率で新しい値を与え、また、一定の確率でString Poolから引用した値を与えることで、新しいテストケースを生成する。この動作を全ての遺伝子に対して実施し、1つのテストケースに対して遺伝子の数だけ新しいテストケースを生成する。突然変異部125は、突然変異によって複数の新しいテストケースを生成し、新しいテストケースをテストスイートTSに追加する。
Next, in step S306 of FIG. 14, the
ステップS306について、図16を参照して更に説明する。 Step S306 will be further described with reference to FIG.
ステップS601において、突然変異部125は、ソートされた素材テストスイートを入力として受け取り、ソートされた素材テストスイートの上から順番に複数のテストケースを抽出する。
In step S601, the
ステップS602において、突然変異部125は、抽出したテストケースを入力として受け取り、テストケースの各テストデータの各遺伝子に対して、遺伝子のvalueの値を一定確率で2種類の操作のうちどちらかによって変更する。2種類の操作のうち一方は、valueの値をランダムな値に変更する操作である。例えば、突然変異部125は、遺伝子のvalue="aaa"を一定確率でvalue="hoge"に変更する。変更する値はどのような値でもよい。2種類の操作のうち他方は、String Poolの中の定数を用いて、valueの値に代入する操作である。
In step S602, the
ステップS602について、図17を参照して更に説明する。 Step S602 will be further described with reference to FIG.
ステップS702において、突然変異部125は、ランダムでステップS703又はステップS704に移行する。
In step S702, the
ステップS703において、突然変異部125は、抽出したテストケースを入力として受け取り、テストケースの各テストデータの各遺伝子に対して、遺伝子のvalueの値を一定確率でランダムな値に変更する。例えば、突然変異部125は、遺伝子のvalue="aaa"を一定確率でvalue="hoge"に変更する。変更する値はどのような値でもよい。また、残りの確率で遺伝子の変更を行わない。確率は予め決められた定数とする。
In step S703, the
ステップS704において、突然変異部125は、空のString Pool(1)、空のString Pool(2)、空のString Pool(3)、空のString Pool(4)を作成する。
In step S704, the
ステップS705において、突然変異部125は、String Poolを入力として受け取り、String Poolの各Pool要素の出典が「事前準備」であるか否かを判断する。出典が「事前準備」である場合、ステップS706に移行し、出典が「事前準備」でない場合、ステップS707に移行する。
In
ステップS706において、突然変異部125は、String PoolとString Pool(4)を入力として受け取り、出典が「事前準備」となっている各Pool要素をString Pool(4)に追加する。
In step S706, the
ステップS707において、突然変異部125は、String Poolと目標分岐結果を入力として受け取り、目標分岐結果の最終判定分岐が属するクラスが、String Poolの各Pool要素の出典のクラス名と一致するか否かを判断する。一致しない場合、ステップS708に移行し、一致する場合、ステップS709に移行する。
In
ステップS708において、突然変異部125は、String PoolとString Pool(3)を入力として受け取り、目標分岐結果の最終判定分岐が属するクラスが出典のクラス名と一致しない各Pool要素をString Pool(3)に追加する。
In step S 708,
ステップS709において、突然変異部125は、String Poolと目標分岐結果を入力として受け取り、目標分岐結果の最終判定分岐が属するメソッドが、String Poolの各Pool要素の出典のメソッド名と一致するか否かを判断する。一致しない場合、ステップS710に移行し、一致する場合、ステップS711に移行する。
In step S 709,
ステップS710において、突然変異部125は、String PoolとString Pool(2)を入力として受け取り、目標分岐結果の最終判定分岐が属するクラスが出典のクラス名と一致するが、目標分岐結果の最終判定分岐が属するメソッドが出典のメソッド名と一致しない各Pool要素をString Pool(2)に追加する。
In step S710,
ステップS711において、突然変異部125は、String PoolとString Pool(1)を入力として受け取り、目標分岐結果の最終判定分岐が属するクラスが出典のクラス名と一致し、且つ、目標分岐結果の最終判定分岐が属するメソッドが出典のメソッド名と一致する各Pool要素をString Pool(1)に追加する。
In step S711,
ステップS712において、突然変異部125は、String Pool(1)、String Pool(2)、String Pool(3)、String Pool(4)を入力として受け取り、String Pool(1)、String Pool(2)、String Pool(3)、String Pool(4)の中から1つを選択する。
In step S712, the
ステップS713において、突然変異部125は、抽出したテストケースと選択したString Poolを入力として受け取り、テストケースの各テストデータの各遺伝子に対して、選択したString Poolから1つのPool要素を選択し、Pool要素の定数を遺伝子のvalueに代入する。なお、String Poolを選択する確率は、String Pool(1)>String Pool(2)>String Pool(3)>String Pool(4)となるように設定されているため、目標分岐結果の最終判定分岐の行数と近い値を持つPool要素が選択される確率が高くなる。なお、行数の近さと確率との相関は事前に設定する。
In step S713, the
突然変異により遺伝子が操作された場合、図16のステップS603に戻る。 If the gene is manipulated by mutation, the process returns to step S603 in FIG.
ステップS603において、突然変異部125は、遺伝子操作されたテストケースとテストスイートTSを入力として受け取り、遺伝子操作されたテストケースをテストスイートTSに追加する。遺伝子操作されたテストケースがテストスイートTSに追加された場合、図14のステップS307に戻る。
In step S603, the
次に、テストスイートTSの各テストケースに対し、以下のように出力テストスイートを生成する。 Next, for each test case of the test suite TS, an output test suite is generated as follows.
図14のステップS307において、SBST部115は、テストスイートTS内のテストケースを入力として受け取り、テスト対象のプログラムにテストスイートTS内のテストケースを実行させる。コード挿入部111が分岐結果を出力するコードを挿入しているため、テストケースに対し、対応する分岐結果が取得できる。
In step S307 in FIG. 14, the
ステップS308において、SBST部115のString Pool部131は、テストスイートTS内のテストケースを入力として受け取り、テスト対象のプログラムにテストスイートTS内のテストケースを実行させる。コード挿入部111がString型の一致判定の箇所にPool要素を出力するコードを挿入しているため、テストケースに対し、対応するPool要素が取得できる。SBST部115のString Pool部131は、String型の一致判定がある場合、文字列の比較対象のオペランドと、出典をString Poolに追加する。なお、ステップS308は、ステップS307と同時に実行されてもよい。
In step S308, the
ステップS309において、SBST部115は、テストスイートTS内のテストケースと、対応する分岐結果と、素材テストスイートを入力として受け取り、テストケースと、対応する分岐結果を素材テストスイートに追加する。
In step S309, the
ステップS310において、SBST部115は、テストスイートTS内のテストケースと、対応する分岐結果と、出力テストスイートを入力として受け取り、SBST部115がテストケースを実行して得られた分岐結果と経路一致する分岐結果が出力テストスイートに存在するか否かを判断する。存在しない場合、ステップS311に移行し、存在する場合、ステップS307に戻り、次のテストケースに対する処理を実施し、全てのテストケースに対する処理が終了した場合、ステップS313に移行する。
In step S310, the
ステップS311において、SBST部115は、テストスイートTS内のテストケースと、対応する分岐結果と、出力テストスイートを入力として受け取り、テストケースと、対応する分岐結果を出力テストスイートに追加する。
In step S311, the
ステップS312において、SBST部115は、SBST部115がテストケースを実行して得られた分岐結果が目標分岐結果と経路一致しているか否かを判断する。経路一致していない場合、ステップS313に移行し、経路一致している場合、図13のステップS206に戻る。
In step S312, the
ステップS313においてg=g+1として、ステップS314においてgが最大世代数GになるまでステップS302に戻り、上記の処理を繰り返す。gが最大世代数になった場合、図13のステップS206に戻る。 In step S313, g = g + 1, and in step S314, the process returns to step S302 until g reaches the maximum generation number G, and the above process is repeated. If g has reached the maximum number of generations, the process returns to step S206 in FIG.
次に、図13のステップS206においてn=n-1として、ステップS207においてnが0になるまでステップS202に戻り、上記の処理を繰り返す。nが0になった場合、ステップS201に戻り、次の分岐結果に対する処理を実施し、全ての分岐結果に対する処理が終了した場合、図6のステップS009に戻る。 Next, in step S206 in FIG. 13, n = n−1, and in step S207, the process returns to step S202 until n becomes 0, and the above process is repeated. If n becomes 0, the process returns to step S201, the process for the next branch result is performed, and when the process for all the branch results is completed, the process returns to step S009 in FIG.
次に、図6のステップS009において、テストデータ生成部105は、出力テストスイートの中の全てのテストケースをファイル等に出力する。
Next, in step S009 in FIG. 6, the test
以上の手順により、テストケース生成装置100は、テストシナリオ及びテストデータの組み合わせであるテストケースを出力することができる。
<本発明の実施例の効果>
本発明の実施例によれば、あるテストシナリオが与えられたときに、文字列のデータ型を含む分岐に対して網羅性の高いテストデータの集合を効率的に生成することが可能になる。
According to the above procedure, the test
<The effect of the embodiment of the present invention>
According to an embodiment of the present invention, given a test scenario, it is possible to efficiently generate a comprehensive set of test data for a branch including a data type of a character string.
特に、SBSTの探索アルゴリズムの1つである遺伝的アルゴリズムの突然変異において、従来は文字列をランダムに生成していたが、分岐を解くために有益であると考えられる文字列をString Poolという保存場所に記憶しておくことで、突然変異においてString Poolに存在する文字列を利用してString型を含む条件分岐に対する網羅性を向上させることが可能になる。 In particular, in mutation of genetic algorithm which is one of search algorithm of SBST, character strings are conventionally generated at random, but the character string considered to be useful for solving a branch is saved as String Pool By storing in a place, it is possible to improve the completeness to conditional branches including the String type by using a string existing in String Pool in mutation.
また、String Poolの文字列の取得箇所が出典として管理されているため、解きたい分岐と関連性の高い文字列がString Poolから選択される可能性が高くなる。 In addition, since the acquisition location of the String Pool string is managed as a source, there is a high possibility that a string highly relevant to the branch to be solved will be selected from the String Pool.
また、Concolic Testing及びSBSTの性質の異なる2つの手法を組み合わせることで、よりカバレッジの高いテストデータが生成できる。ただし、2つの手法を順番に実行すると、テストデータの生成にかなりの時間を要するため、Concolic Testingを実行している間にSBSTで必要な情報を予め取得することで、SBSTにおけるテストデータの効率的な探索を可能としている。その結果、プログラムの構造的欠陥によるバグの検出能力が向上する。 Also, by combining two methods with different properties of Concolic Testing and SBST, test data with higher coverage can be generated. However, if two methods are executed in order, it takes a considerable amount of time to generate test data, so by acquiring necessary information in SBST beforehand while executing Concolic Testing, the efficiency of the test data in SBST can be increased. Search is possible. As a result, the ability to detect bugs due to structural defects in the program is improved.
また、テストシナリオをViewの遷移図から生成することにより、Webアプリケーションにおける画面遷移に対する網羅性の高いテストケースが自動生成できる。WebアプリケーションにおけるViewは画面に非常に近い粒度を持つため、Viewの遷移図に対して状態遷移図に対する所定のカバレッジ基準を用いてテストシナリオを抽出することで、画面遷移の粒度に近く、また、画面遷移に対する網羅性の高いテストシナリオを自動生成できる。 Also, by generating a test scenario from the view transition diagram, it is possible to automatically generate an exhaustive test case for screen transition in the Web application. Since the View in the Web application has a granularity very close to the screen, extracting the test scenario using the predetermined coverage criteria for the state transition diagram with respect to the transition diagram of the View makes it close to the granularity of the screen transition and It is possible to automatically generate a comprehensive test scenario for screen transition.
更に、Concolic TestingやSBSTによってテストデータを生成するときに、フレームワークやライブラリ等のユーザが記述していない箇所に対して分岐を解析しないことで、計算爆発を回避することができ、従って、結合テストレベルのテストケースも生成できる。フレームワークやライブラリ等のユーザが記述していない箇所に対してカバレッジを向上させるようなテストケースを生成せず、その代わりに、解析対象のユーザ記述クラスに対するカバレッジの高いテストケース生成に計算リソースを割り当てることができる。 Furthermore, when test data is generated by Concolic Testing or SBST, computational explosion can be avoided by not analyzing branches to locations not described by the user, such as frameworks and libraries, and thus combining Test level test cases can also be generated. Do not generate test cases that improve coverage for areas not described by users such as frameworks and libraries, but instead, use computational resources to generate test cases with high coverage for the user description class to be analyzed It can be assigned.
説明の便宜上、本発明の実施例に係るテストケース生成装置は機能的なブロック図を用いて説明しているが、本発明の実施例に係るテストケース生成装置は、ハードウェア、ソフトウェア又はそれらの組み合わせで実現されてもよい。例えば、本発明の実施例は、コンピュータに対して本発明の実施例に係るテストケース生成装置の各機能を実現させるプログラム、コンピュータに対して本発明の実施例に係るテストケース生成方法の各手順を実行させるプログラム等により、実現されてもよい。また、各機能部が必要に応じて組み合わせて使用されてもよい。また、本発明の実施例に係るテストケース生成方法は、実施例に示す順序と異なる順序で実施されてもよい。 Although the test case generation apparatus according to the embodiment of the present invention is described using a functional block diagram for convenience of explanation, the test case generation apparatus according to the embodiment of the present invention may be hardware, software, or theirs. It may be realized in combination. For example, an embodiment of the present invention is a program that causes a computer to realize each function of a test case generation device according to an embodiment of the present invention, and each procedure of a test case generation method according to an embodiment of the present invention for a computer May be realized by a program or the like that executes. Also, each functional unit may be used in combination as needed. In addition, the test case generation method according to the embodiment of the present invention may be performed in an order different from the order shown in the embodiment.
以上、あるテストシナリオが与えられたときに、文字列のデータ型を含む分岐に対して網羅性の高いテストデータの集合を効率的に生成するための手法について説明したが、本発明は、上記の実施例に限定されることなく、特許請求の範囲内において、種々の変更・応用が可能である。 The above describes the method for efficiently generating a comprehensive test data set for a branch including a data type of a string when given a test scenario. Various modifications and applications are possible within the scope of the claims, without being limited to the embodiments of the invention.
100 テストケース生成装置
101 VCシナリオ生成部
103 テストシナリオ生成部
105 テストデータ生成部
111 コード挿入部
113 Concolic Testing部
115 SBST部
121 選択部
123 交叉部
125 突然変異部
131 String Pool部
100 test
Claims (7)
テストデータの生成に用いられる文字列の集合を取得する文字列集合取得機能と、
テスト対象のプログラムに、分岐の判定を定量的に評価するための評価値を含む分岐結果を出力するコードを挿入するコード挿入機能と、
指定のテストシナリオに対するテストデータを生成すると共に、前記挿入されたコードが出力した分岐結果を生成する第1テストデータ生成機能と、
前記生成された分岐結果に対して途中まで経路一致する目標分岐結果を生成し、前記取得された文字列の集合の中から選択された文字列を遺伝的アルゴリズムにおいて用いて、当該目標分岐結果を満たすテストデータを生成する第2のテストデータ生成機能と、
を実現させるためのテストデータ生成プログラム。 A test data generation program for generating test data for a specified test scenario, the computer comprising:
A character string set acquisition function for acquiring a set of character strings used to generate test data;
A code insertion function for inserting into the program to be tested a code that outputs a branch result including an evaluation value for quantitatively evaluating the determination of the branch;
A first test data generation function of generating test data for a specified test scenario and generating a branch result output from the inserted code;
A target branch result that matches the path halfway to the generated branch result is generated, and a character string selected from among the acquired character string set is used in a genetic algorithm, and the target branch result is generated. A second test data generation function for generating test data to be satisfied;
Test data generator for realizing.
前記文字列集合取得機能は、前記目標分岐結果を満たすテストデータを生成する過程において、前記挿入されたコードによって出力された文字列を取得する、請求項1乃至4のうちいずれか1項に記載のテストデータ生成プログラム。 The code insertion function inserts a code for outputting a character string at a position where the data type of the character string of the program to be tested matches.
The character string set acquisition function according to any one of claims 1 to 4, wherein, in the process of generating test data satisfying the target branch result, the character string outputted by the inserted code is acquired. Test data generator.
コンピュータに、
Controllerの情報を用いてViewの遷移図を生成し、当該Viewの遷移図から状態遷移図に対する所定のカバレッジ基準に基づいてView及びControllerの繋がりを表すVCシナリオを生成するVCシナリオ生成機能と、
前記生成されたVCシナリオにView操作情報を追加したテストシナリオを生成するテストシナリオ生成機能と、
を更に実現させ、
前記指定のテストシナリオは、前記テストシナリオ生成機能により生成されたテストシナリオから選択される、請求項1乃至5のうちいずれか1項に記載のテストデータ生成プログラム。 If the program to be tested consists of at least View and Controller,
On the computer
A VC scenario generation function of generating a transition diagram of a view using controller information, and generating a VC scenario representing a connection between the view and the controller based on a predetermined coverage criterion for the state transition diagram from the view transition diagram;
A test scenario generation function of generating a test scenario in which View operation information is added to the generated VC scenario;
To realize
The test data generation program according to any one of claims 1 to 5, wherein the specified test scenario is selected from the test scenario generated by the test scenario generation function.
前記テストデータ生成装置が、テストデータの生成に用いられる文字列の集合を取得するステップと、
前記テストデータ生成装置が、テスト対象のプログラムに、分岐の判定を定量的に評価するための評価値を含む分岐結果を出力するコードを挿入するステップと、
前記テストデータ生成装置が、指定のテストシナリオに対するテストデータを生成すると共に、前記挿入されたコードが出力した分岐結果を生成するステップと、
前記テストデータ生成装置が、前記生成された分岐結果に対して途中まで経路一致する目標分岐結果を生成し、前記取得された文字列の集合の中から選択された文字列を遺伝的アルゴリズムにおいて用いて、当該目標分岐結果を満たすテストデータを生成するステップと、
を有するテストデータ生成方法。 A test data generation method in a test data generation apparatus for generating test data for a specified test scenario, comprising:
The test data generation device acquiring a set of character strings used for generation of test data;
Inserting, in the program to be tested, a code that outputs a branch result including an evaluation value for quantitatively evaluating the determination of a branch, into the program to be tested;
The test data generator generating test data for a specified test scenario and generating a branch result output from the inserted code;
The test data generation device generates a target branch result that matches the path halfway to the generated branch result, and uses a character string selected from the acquired character string set in a genetic algorithm Generating test data satisfying the target branch result;
A test data generation method having:
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
JP2016085943A JP6533484B2 (en) | 2016-04-22 | 2016-04-22 | Test data generation program and test data generation method |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
JP2016085943A JP6533484B2 (en) | 2016-04-22 | 2016-04-22 | Test data generation program and test data generation method |
Publications (2)
Publication Number | Publication Date |
---|---|
JP2017194895A JP2017194895A (en) | 2017-10-26 |
JP6533484B2 true JP6533484B2 (en) | 2019-06-19 |
Family
ID=60156455
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
JP2016085943A Active JP6533484B2 (en) | 2016-04-22 | 2016-04-22 | Test data generation program and test data generation method |
Country Status (1)
Country | Link |
---|---|
JP (1) | JP6533484B2 (en) |
Families Citing this family (3)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
JP7016583B2 (en) * | 2018-04-19 | 2022-02-07 | 東芝情報システム株式会社 | Software testing methods, systems and programs |
JP7062581B2 (en) * | 2018-12-07 | 2022-05-06 | Kddi株式会社 | Privacy policy verification device, computer program and privacy policy verification method |
TWI781354B (en) * | 2019-11-11 | 2022-10-21 | 財團法人資訊工業策進會 | System and method for producing test data |
Family Cites Families (3)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
JPH07219754A (en) * | 1994-01-31 | 1995-08-18 | Toshiba Corp | Request definition support device using screen transition diagram |
JP2007109033A (en) * | 2005-10-14 | 2007-04-26 | Hitachi Software Eng Co Ltd | Screen transition management device and screen transition management program |
JP5203806B2 (en) * | 2008-06-06 | 2013-06-05 | インターナショナル・ビジネス・マシーンズ・コーポレーション | Sequence diagram creation apparatus, sequence diagram creation method, and computer program |
-
2016
- 2016-04-22 JP JP2016085943A patent/JP6533484B2/en active Active
Also Published As
Publication number | Publication date |
---|---|
JP2017194895A (en) | 2017-10-26 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
Ensan et al. | Evolutionary search-based test generation for software product line feature models | |
JP6533484B2 (en) | Test data generation program and test data generation method | |
US11204860B2 (en) | Methods and apparatuses for generating smart contract test case | |
Gupta et al. | Using genetic algorithm for unit testing of object oriented software | |
CN109146081A (en) | It is a kind of for quickly creating the method and device of model item in machine learning platform | |
Zhang et al. | Analysis of security of split manufacturing using machine learning | |
CN111581092A (en) | Method for generating simulation test data, computer device and storage medium | |
US8266573B2 (en) | Method and system for test point insertion | |
Van Elk et al. | Improved uncertainty management in field development studies through the application of the experimental design method to the multiple realisations approach | |
Simonetto et al. | Visualise undrawable Euler diagrams | |
US20160019318A1 (en) | Problem structure extraction support system, problem structure extraction support method, and program | |
JP2017194892A (en) | Test case production program and test case production method | |
US8418119B2 (en) | Logical circuit netlist reduction and model simplification using simulation results containing symbolic values | |
JP6572168B2 (en) | Test data generation program and test data generation method | |
US20120290282A1 (en) | Reachability analysis by logical circuit simulation for providing output sets containing symbolic values | |
Huppe et al. | Mining complex temporal api usage patterns: an evolutionary approach | |
JP6572167B2 (en) | Test data generation program and test data generation method | |
CN104915430B (en) | A kind of restriction relation rough set regulation obtaining method based on MapReduce | |
Mariano et al. | Analyzing graph-based algorithms employed to generate test cases from finite state machines | |
EP3109773A1 (en) | Relatedness graph evaluation system | |
Srivastava et al. | Use of genetic algorithm in generation of feasible test data | |
JP5075695B2 (en) | Property description coverage measuring apparatus and program | |
Ceylan et al. | GraphDCA--a Framework for Node Distribution Comparison in Real and Synthetic Graphs | |
Wibowo et al. | Unit test code generator for lua programming language | |
Verbeek et al. | Visualizing state spaces with Petri nets |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
A621 | Written request for application examination |
Free format text: JAPANESE INTERMEDIATE CODE: A621 Effective date: 20180213 |
|
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: 20190521 |
|
A61 | First payment of annual fees (during grant procedure) |
Free format text: JAPANESE INTERMEDIATE CODE: A61 Effective date: 20190524 |
|
R150 | Certificate of patent or registration of utility model |
Ref document number: 6533484 Country of ref document: JP Free format text: JAPANESE INTERMEDIATE CODE: R150 |