JP5755861B2 - Test case generation apparatus, test case generation method, and test case generation program - Google Patents

Test case generation apparatus, test case generation method, and test case generation program Download PDF

Info

Publication number
JP5755861B2
JP5755861B2 JP2010204439A JP2010204439A JP5755861B2 JP 5755861 B2 JP5755861 B2 JP 5755861B2 JP 2010204439 A JP2010204439 A JP 2010204439A JP 2010204439 A JP2010204439 A JP 2010204439A JP 5755861 B2 JP5755861 B2 JP 5755861B2
Authority
JP
Japan
Prior art keywords
path
test case
predicate
unit
determination
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Active
Application number
JP2010204439A
Other languages
Japanese (ja)
Other versions
JP2012059202A (en
Inventor
真則 高岡
真則 高岡
宮本 剛
剛 宮本
典彦 鎌田
典彦 鎌田
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
NEC Communication Systems Ltd
Original Assignee
NEC Communication Systems 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 NEC Communication Systems Ltd filed Critical NEC Communication Systems Ltd
Priority to JP2010204439A priority Critical patent/JP5755861B2/en
Publication of JP2012059202A publication Critical patent/JP2012059202A/en
Application granted granted Critical
Publication of JP5755861B2 publication Critical patent/JP5755861B2/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Description

本発明は、テストケース生成装置、テストケース生成方法およびテストケース生成プログラムに関する。   The present invention relates to a test case generation device, a test case generation method, and a test case generation program.

ソフトウェアの開発において、そのソフトウェアを搭載した製品が仕様を満たしているかどうかを確認したり、製品の品質を確認したりするために、ソフトウェアのテストが実施される。このテストは、重要な工程である。   In software development, software testing is performed to check whether a product on which the software is installed satisfies the specifications or to check the quality of the product. This test is an important step.

ソフトウェアの内部構造の分析を基にしたテストとして、ホワイトボックステストがある。ホワイトボックステストとは、テスト対象のソフトウェアの内部構造に関する知識を拠り所にして、テスト対象のソフトウェアが正常に機能するかどうかを確認するテストである。   There is a white box test as a test based on the analysis of the internal structure of the software. The white box test is a test for confirming whether or not the software to be tested functions normally based on knowledge about the internal structure of the software to be tested.

ホワイトボックステストの1つとして、パステストがある。パステストとは、プログラム中のコードがすべて実行されるようなテストデータに基づいてテストする技法である。パステストでは、テスト対象のソフトウェアからパス、すなわち制御フローパスを選択し、そのパスをテストする。具体的には、パステストでは、テスト対象のソフトウェアへの入力値および事前条件が予め決定された上でテストの対象ソフトウェアが実行される。そして、テストの結果が期待結果および事後条件を満たすかどうかを判定することにより、テスト対象のソフトウェアが正常に機能するかどうかを確認する。パステストは、制御フローテストとも呼ばれる。   One of the white box tests is a pass test. The path test is a technique for testing based on test data such that all code in a program is executed. In the path test, a path, that is, a control flow path is selected from the test target software, and the path is tested. Specifically, in the pass test, the test target software is executed after the input value and preconditions for the test target software are determined in advance. Then, it is determined whether or not the software to be tested functions normally by determining whether or not the test result satisfies the expected result and the post-condition. The path test is also called a control flow test.

パステスト法は、ソフトウェアのテストの基本的手法である。例えば、非特許文献1および非特許文献2に、パステスト法が記載されている。   The path test method is a basic method for testing software. For example, Non-Patent Document 1 and Non-Patent Document 2 describe a path test method.

パステストを行う場合、予め、選択されたパスと、そのパスを実行するための入力値や事前条件、および期待結果と事後条件を含むテストケースが定められる。   When performing a path test, a test case including a selected path, an input value and a precondition for executing the path, and an expected result and a postcondition are determined in advance.

非特許文献1および非特許文献2は、パステストの設計を人が行う方法を開示する。また、特許文献1および特許文献2は、上記パステストの設計を自動化したシステムの例を開示する。   Non-Patent Document 1 and Non-Patent Document 2 disclose a method in which a person performs path test design. Patent Documents 1 and 2 disclose examples of systems that automate the design of the path test.

ボーリス・バイザー著、「ソフトウェアテスト技法」、日経BP出版センター、1994年2月25日、pp.49−97Boris Visor, “Software Testing Techniques”, Nikkei BP Publishing Center, February 25, 1994, pp. 49-97 リー・コープランド著、「はじめて学ぶソフトウェアのテスト技法」、日経BP社、2005年11月7日、pp.125−148Lee Copeland, “First-time Software Testing Techniques”, Nikkei Business Publications, November 7, 2005, pp. 125-148

特開2008−299502号公報JP 2008-299502 A 特開2004−220269号公報Japanese Patent Laid-Open No. 2004-220269

上述したようなパステストの設計においては、選択されたパスが、いかなる入力値を組み合わせ、また設定しても、実行できない実行不可能パスが存在する。情報システム等のソフトウェアでは、フラグの意味を表わす変数を利用することによりパスを選択しており、通例、プログラム中にはフラグ条件による分岐箇所が多数存在する。   In the path test design as described above, there is an infeasible path that cannot be executed even if the selected path is combined and set with any input value. In software such as an information system, a path is selected by using a variable representing the meaning of a flag, and there are usually many branch points due to flag conditions in a program.

あるフラグがある処理中に不変である場合、ある分岐条件ではフラグが真の側に分岐し、別のある分岐ではそのフラグが偽の側に分岐することはあり得ない。このようなパスを実行不可能パスと称する。実行不可能パスがテストケースに含まれると、テストの効率が低下するという課題がある。   When a certain flag is unchanged during a certain process, the flag cannot branch to the true side under a certain branch condition, and the flag cannot branch to the false side under another branch. Such a path is called an infeasible path. When an infeasible path is included in a test case, there is a problem that test efficiency decreases.

上記いずれの先行技術文献においても、実行不可能パスがテストケースに含まれるという課題がある。   In any of the above prior art documents, there is a problem that an infeasible path is included in the test case.

本願発明は、上記課題を鑑みてなされたものであり、ソースコードが表すコンピュータプログラムのテスト効率を向上するテストケース生成装置、テストケース生成方法およびテストケース生成プログラムを提供することを主要な目的とする。   The present invention has been made in view of the above problems, and has as its main object to provide a test case generation device, a test case generation method, and a test case generation program that improve the test efficiency of a computer program represented by source code. To do.

本発明に係るテストケース生成装置は、入力されたソースコードから、そのソースコードが表すコンピュータプログラムが実行されたときの流れを示すパスをテストケースとして抽出すると共に、該抽出したパスに含まれる判断条件を抽出する抽出手段と、前記抽出された判断条件に基づいて、前記パスが実行可能であるか否かを判定し、実行可能でないと判定された場合、該パスを前記テストケースから除外する判定手段とを備える。   The test case generation device according to the present invention extracts, from the input source code, a path indicating a flow when the computer program represented by the source code is executed as a test case, and a determination included in the extracted path Based on extraction means for extracting a condition and the extracted determination condition, it is determined whether or not the path is executable. If it is determined that the path is not executable, the path is excluded from the test case. Determination means.

本発明に係るテストケース生成方法は、入力されたソースコードから、そのソースコードが表すコンピュータプログラムが実行されたときの流れを示すパスをテストケースとして抽出すると共に、該抽出したパスに含まれる判断条件を抽出し、前記抽出された判断条件に基づいて、前記パスが実行可能であるか否かを判定し、実行可能でないと判定された場合、該パスを前記テストケースから除外することを備える。   The test case generation method according to the present invention extracts, as a test case, a path indicating a flow when a computer program represented by the source code is executed from the input source code, and a determination included in the extracted path Extracting a condition, determining whether or not the path is executable based on the extracted determination condition, and removing the path from the test case when it is determined that the path is not executable .

なお同目的は、上記の各構成を有するテストケース生成装置、並びに対応する方法を、コンピュータによって実現するコンピュータ・プログラム、およびそのコンピュータ・プログラムが格納されている、コンピュータ読み取り可能な記憶媒体によっても達成される。   This object is also achieved by a computer program for realizing the test case generation apparatus having the above-described configurations and the corresponding method by a computer, and a computer-readable storage medium storing the computer program. Is done.

本願発明によれば、ソースコードが表すコンピュータプログラムのテスト効率を向上することができる効果が得られる。   According to the present invention, it is possible to improve the test efficiency of the computer program represented by the source code.

本発明の第1の実施形態に係るテストケース生成装置の構成を示すブロック図である。It is a block diagram which shows the structure of the test case production | generation apparatus which concerns on the 1st Embodiment of this invention. 本発明の第1の実施形態に係るテストケース生成装置のハードウエア構成を示す図である。It is a figure which shows the hardware constitutions of the test case production | generation apparatus which concerns on the 1st Embodiment of this invention. 本発明の第1の実施形態に係るテストケース生成装置の動作を示すフローチャートである。It is a flowchart which shows operation | movement of the test case production | generation apparatus which concerns on the 1st Embodiment of this invention. 本発明の第1の実施形態に係るテストケース生成装置により生成されるテストケースの具体例を示す図である。It is a figure which shows the specific example of the test case produced | generated by the test case production | generation apparatus which concerns on the 1st Embodiment of this invention. 本発明の第2の実施形態に係るテストケース生成装置により生成されるテストケースの具体例を示す図である。It is a figure which shows the specific example of the test case produced | generated by the test case production | generation apparatus which concerns on the 2nd Embodiment of this invention. 本発明の第3の実施形態に係るテストケース生成装置により生成されるテストケースの具体例を示す図である。It is a figure which shows the specific example of the test case produced | generated by the test case production | generation apparatus which concerns on the 3rd Embodiment of this invention. 本発明の第4の実施形態に係るテストケース生成装置の構成を示すブロック図である。It is a block diagram which shows the structure of the test case production | generation apparatus which concerns on the 4th Embodiment of this invention.

第1の実施形態
次に、本発明の実施形態について図面を参照して詳細に説明する。
First Embodiment Next, an embodiment of the present invention will be described in detail with reference to the drawings.

図1は、本発明の第1の実施形態に係るテストケース生成装置10の構成を示すブロック図である。図1に示すように、テストケース生成装置10は、入力部11、パス解析部12、述語正規化部13、実行可能性判定部14、パス解析結果記憶部15および出力部16を備える。   FIG. 1 is a block diagram showing a configuration of a test case generation apparatus 10 according to the first embodiment of the present invention. As illustrated in FIG. 1, the test case generation device 10 includes an input unit 11, a path analysis unit 12, a predicate normalization unit 13, an feasibility determination unit 14, a path analysis result storage unit 15, and an output unit 16.

図1のテストケース生成装置10は、コンピュータにより実現した場合、それぞれ図2に示すハードウエア構成を有する。図2に示す構成は、CPU(Central Processing Unit)40、メモリ等の記憶媒体41および記憶媒体41に含まれるプログラム42を備える。テストケース生成装置10のCPU40は、各種ソフトウエア・プログラム(コンピュータ・プログラム)を実行することにより、テストケース生成装置10の全体的な動作を司る。本実施形態および以下に示す他の実施形態において、CPU40が、メモリ等の記憶媒体41を適宜参照しながら、以下に示すテストケース生成装置10が備える各機能(各部)のソフトウエア・プログラムを実行する。   The test case generation device 10 in FIG. 1 has a hardware configuration shown in FIG. 2 when implemented by a computer. The configuration shown in FIG. 2 includes a CPU (Central Processing Unit) 40, a storage medium 41 such as a memory, and a program 42 included in the storage medium 41. The CPU 40 of the test case generation apparatus 10 controls the overall operation of the test case generation apparatus 10 by executing various software programs (computer programs). In this embodiment and other embodiments described below, the CPU 40 executes a software program for each function (each unit) included in the test case generation device 10 described below while appropriately referring to a storage medium 41 such as a memory. To do.

より具体的には、CPU40は、メモリ等の記憶媒体41を適宜参照しながら、テストケース生成装置10が備える入力部11、パス解析部12等のソフトウエア・プログラムを実行する。   More specifically, the CPU 40 executes software programs such as the input unit 11 and the path analysis unit 12 included in the test case generation apparatus 10 while appropriately referring to a storage medium 41 such as a memory.

テストケース生成装置10の概要について説明する。   An outline of the test case generation device 10 will be described.

入力部11は、ソースコードを読み出すと共に、読み出したソースコードをパス解析部12に通知するする。入力部11は、例えば、ソースコード記憶部20等のハードディスクの記憶媒体に蓄積されているソースコードを読み出す機能を有する。また、入力部11は、ネットワークを介してソースコードを読み出す機能等を有してもよい。   The input unit 11 reads the source code and notifies the path analysis unit 12 of the read source code. The input unit 11 has a function of reading source code stored in a hard disk storage medium such as the source code storage unit 20. The input unit 11 may have a function of reading source code via a network.

パス解析部12は、入力部11からソースコードを受け取ると共に、受け取ったソースコードから、処理の流れとしてあり得る全てのパスを抽出する。パスとは、ソースコードが表すコンピュータプログラムが実行されたときの流れを表し、コンピュータプログラムの実行に際してソースコードにおけるどの箇所を通るかを示す情報である。   The path analysis unit 12 receives the source code from the input unit 11 and extracts all possible paths as a processing flow from the received source code. A path represents a flow when a computer program represented by a source code is executed, and is information indicating which part of the source code passes when the computer program is executed.

また、パス解析部12は、抽出したパスから、そのパスを制御する条件分岐における述語を抽出する。パスを制御する条件分岐における述語とは、ソースコード中の条件により分岐する箇所における判断条件を表す情報である(詳細は、図4を参照して後述する)。パス解析部12は、抽出したパスと述語とを、パス解析結果記憶部15に保存する。   The path analysis unit 12 extracts a predicate in a conditional branch that controls the path from the extracted path. The predicate in the conditional branch for controlling the path is information indicating a determination condition at a location where the branch is caused by the condition in the source code (details will be described later with reference to FIG. 4). The path analysis unit 12 stores the extracted path and predicate in the path analysis result storage unit 15.

述語正規化部13は、パス解析結果記憶部15から述語を読み出すと共に、読み出した述語を正規化して、再びパス解析結果記憶部15に保存する。ここで、述語の正規化とは、述語同士を比較可能にするために、述語の意味を変えずに表式のみを変更することである(詳細は、図4を参照して後述する)。   The predicate normalization unit 13 reads the predicate from the path analysis result storage unit 15, normalizes the read predicate, and saves it in the path analysis result storage unit 15 again. Here, normalization of the predicate is to change only the expression without changing the meaning of the predicate so that the predicates can be compared with each other (details will be described later with reference to FIG. 4).

実行可能性判定部14は、パス解析結果記憶部15からパスおよびそのパスに含まれる正規化された述語を読み出すと共に、そのパスが実行可能かどうかを判定する。具体的には、実行可能性判定部14は、パスに含まれる正規化された2つの述語を読み出すと共にそれらを比較する。そして、実行可能性判定部14は、2つの述語の意味が同一か否か、あるいは一方が成立するとき他方が成立し得ない排反であるかどうか等を判定し、その判定結果に基づいて、そのパスが実行可能かどうかを判定する。   The feasibility determination unit 14 reads the path and the normalized predicate included in the path from the path analysis result storage unit 15 and determines whether the path is executable. Specifically, the feasibility determination unit 14 reads two normalized predicates included in the path and compares them. Then, the feasibility determination unit 14 determines whether or not the meanings of the two predicates are the same, or whether or not the other is not possible when one is satisfied, and based on the determination result Determine if the path is executable.

実行可能性判定部14は、2つの述語が実行の流れにおいて同時に成立し得ない場合、それらの述語を含むパスを実行不可能であると判定する。実行可能性判定部14は、実行不可能であると判定したパスを除いたパスの集合を、テストケースとして出力部16に通知する。   If the two predicates cannot be satisfied at the same time in the execution flow, the feasibility determination unit 14 determines that the path including these predicates is not executable. The feasibility determination unit 14 notifies the output unit 16 of a set of paths excluding paths determined to be unexecutable as test cases.

出力部16は、実行可能性判定部14により得られた実行不可能なパスを含まないテストケースを出力する。出力部16は、例えば、テストケース記憶部30等のハードディスク等の記憶媒体に、結果を蓄積する機能を有する。また、出力部16は、テストケースを画面出力したりネットワークを介して出力したりするなど、様々な出力形態を有してもよい。   The output unit 16 outputs a test case that does not include an infeasible path obtained by the feasibility determination unit 14. The output unit 16 has a function of accumulating results in a storage medium such as a hard disk such as the test case storage unit 30. Further, the output unit 16 may have various output forms such as outputting a test case on a screen or via a network.

図3は、テストケース生成装置10の動作を示すフローチャートである。また、図4は、テストケース生成装置10により生成されたテストケースの具体例を示す図である。図3、図4を参照して、テストケース生成装置10の動作について説明する。   FIG. 3 is a flowchart showing the operation of the test case generation apparatus 10. FIG. 4 is a diagram illustrating a specific example of a test case generated by the test case generation apparatus 10. The operation of the test case generation device 10 will be described with reference to FIGS.

テストケース生成装置10の入力部11は、テストケースの生成にあたり、ソースコード記憶部20からソースコードを読み出すと共に、読み出したソースコードをパス解析部12に通知する。パス解析部12は、入力部11からソースコードを取得すると、そのソースコードから全てのパス、あるいはある指定された特定の条件下におけるパスの集合を抽出すると共に、抽出したパスをパス解析結果記憶部15に保存する(ステップS101)。   When generating the test case, the input unit 11 of the test case generation apparatus 10 reads the source code from the source code storage unit 20 and notifies the path analysis unit 12 of the read source code. When the path analysis unit 12 acquires the source code from the input unit 11, the path analysis unit 12 extracts all paths or a set of paths under a certain specified condition from the source code, and stores the extracted paths in the path analysis result. The data is stored in the unit 15 (step S101).

例えば、ソースコードが図4に示すものである場合について説明する。ソースコード51は、以下の内容を示す。すなわち、まず、処理1が実行される。次に、述語Aとして「x>0」を持った条件分岐「if」文があり、述語Aが真のときに処理2が実行され、述語Aが偽のときに処理3が実行される。次に、処理4が実行される。次に、述語Bとして述語Aと同一の「x>0」を持った条件分岐「if」文があり、述語Bが真のときに処理5が実行され、述語Bが偽のときに処理6が実行される。次に処理7が実行される。   For example, a case where the source code is as shown in FIG. 4 will be described. The source code 51 shows the following contents. That is, first, process 1 is executed. Next, there is a conditional branch “if” statement having “x> 0” as the predicate A, and the process 2 is executed when the predicate A is true, and the process 3 is executed when the predicate A is false. Next, process 4 is executed. Next, there is a conditional branch “if” statement having the same “x> 0” as predicate A as predicate B, and processing 5 is executed when predicate B is true, and processing 6 is performed when predicate B is false. Is executed. Next, process 7 is executed.

パス解析部12は、上記ソースコード51から、実行の流れとしてあり得る全てのパスを抽出する。すなわち、
パス1として、1(A真)24(B真)57
パス2として、1(A偽)34(B真)57
パス3として、1(A真)24(B偽)67
パス4として、1(A偽)34(B偽)67
というパスを抽出する。ここで、上記パスの表記において、「1」〜「7」の表記は処理名を表し、「A」、「B」の表記は述語名を表す。また、述語の後ろの「真偽」の表記は、述語が真または偽であることを表す。上記表記の順番に処理が実行される。パス解析部12は、上記抽出したパスをパス解析結果記憶部15に保存する。
The path analysis unit 12 extracts all possible paths from the source code 51 as an execution flow. That is,
As pass 1, 1 (A true) 24 (B true) 57
As pass 2, 1 (A false) 34 (B true) 57
As pass 3, 1 (A true) 24 (B false) 67
As pass 4, 1 (A false) 34 (B false) 67
Extract the path. In the path notation, “1” to “7” represent process names, and “A” and “B” represent predicate names. The notation “true / false” after the predicate indicates that the predicate is true or false. Processing is performed in the order of the above description. The path analysis unit 12 stores the extracted path in the path analysis result storage unit 15.

パス解析部12は、続いて、抽出したパスから述語を抽出する(ステップS102)。すなわち、パス解析部12はまず、パス1から述語を抽出する。述語Aとして「x>0」、述語Bとして「x>0」が、それぞれ抽出される。パス解析部12は、抽出した述語A、Bを、パス解析結果記憶部15に保存する。   Next, the path analysis unit 12 extracts a predicate from the extracted path (step S102). That is, the path analysis unit 12 first extracts a predicate from the path 1. “X> 0” is extracted as the predicate A, and “x> 0” is extracted as the predicate B. The path analysis unit 12 stores the extracted predicates A and B in the path analysis result storage unit 15.

続いて、述語正規化部13は、パス解析部12により保存された述語を正規化し、その結果をパス解析結果記憶部15に保存する(ステップS103)。すなわち、述語正規化部13は、述語Aを「x>0」、述語Bを「x>0」のように、それぞれ正規化すると共に、述語Aと述語Bとが等価であることを判断(認識)する。そして、述語正規化部13は正規化した結果と、述語Aと述語Bとが等価であることとを、パス解析結果記憶部15に保存する。   Subsequently, the predicate normalization unit 13 normalizes the predicate stored by the path analysis unit 12, and stores the result in the path analysis result storage unit 15 (step S103). That is, the predicate normalization unit 13 normalizes the predicate A to “x> 0” and the predicate B to “x> 0”, respectively, and determines that the predicate A and the predicate B are equivalent ( recognize. Then, the predicate normalization unit 13 saves the normalized result and the predicate A and the predicate B are equivalent in the path analysis result storage unit 15.

続いて、実行可能性判定部14は、パス解析結果記憶部15に格納される正規化された述語に基づいて、パスが実行可能かどうかを判定し、判定結果を出力部16に出力する(ステップS104)。   Subsequently, the feasibility determination unit 14 determines whether or not the path is executable based on the normalized predicate stored in the path analysis result storage unit 15 and outputs the determination result to the output unit 16 ( Step S104).

ここでは、図4に示すように、述語Aと述語Bは等価である。よって、「述語Aが真」かつ「述語Bが偽」、および「述語Aが偽」かつ「述語Bが真」というケースは、成り立たない。したがって、実行可能性判定部14は、そのような条件を含むパスを実行不可能パスであると判断すると共に、該パスを、パス解析結果記憶部15に保存したパスの集合から除外したものを、テストケースとして出力部16に出力する。この場合、実行不可能なパスは、パス2、パス3である。したがって、実行可能性判定部14は、パス1とパス4とを含むパスの集合を、テストケースとして出力部16に出力する。   Here, as shown in FIG. 4, predicate A and predicate B are equivalent. Therefore, the cases where “predicate A is true” and “predicate B is false” and “predicate A is false” and “predicate B is true” are not satisfied. Therefore, the feasibility determination unit 14 determines that a path including such a condition is an infeasible path, and excludes the path from the set of paths stored in the path analysis result storage unit 15. The result is output to the output unit 16 as a test case. In this case, the non-executable paths are path 2 and path 3. Therefore, the feasibility determination unit 14 outputs a set of paths including the path 1 and the path 4 to the output unit 16 as a test case.

以上のように、この第1の実施形態によれば、テストケース生成装置10のパス解析部12が、ソースコードからパスを抽出すると共に、抽出したパスから述語を抽出し、述語正規化部13が、抽出した述語を正規化する。そして、実行可能性判定部14が、正規化された述語に基づいて、パスが実行可能か否かを判定する。実行可能性判定部14は、実行不可能なパスを除外したパスの集合を、テストケースとして出力する。本実施形態は上記構成を有するので、テスト実施者がテストを実施する前にテストケースが実行可能であるかどうかを判断することが不要になるという効果が得られる。また、テストケースから実行不可能なパスを除外できるため、テストケース数が少なくなり、ソースコードが表すコンピュータプログラムのテスト効率を向上することができるという効果が得られる。   As described above, according to the first embodiment, the path analysis unit 12 of the test case generation apparatus 10 extracts a path from the source code, extracts a predicate from the extracted path, and predicate normalization unit 13 Normalizes the extracted predicates. Then, the feasibility determination unit 14 determines whether or not the path is executable based on the normalized predicate. The feasibility determination unit 14 outputs a set of paths excluding non-executable paths as a test case. Since the present embodiment has the above-described configuration, it is possible to obtain an effect that it is not necessary for the tester to determine whether the test case can be executed before the test is performed. In addition, since it is possible to exclude non-executable paths from the test cases, the number of test cases is reduced, and the test efficiency of the computer program represented by the source code can be improved.

なお、本第1の実施形態および以下の各実施形態において、述語同士の関係を判断することは、述語正規化部13により実施されることに限らず、実行可能性判定部14により実施されてもよい。   In the first embodiment and each of the following embodiments, determining the relationship between predicates is not limited to being performed by the predicate normalization unit 13 but is performed by the feasibility determination unit 14. Also good.

第2の実施形態
第2の実施形態では、上記第1の実施形態において説明したテストケース生成装置10によりテストケースを生成する別の例について説明する。
Second Embodiment In the second embodiment, another example in which a test case is generated by the test case generation apparatus 10 described in the first embodiment will be described.

図5は、テストケース生成装置10により生成されるテストケースの具体例を示す図である。図5に示すソースコード52は、図4に示したソースコード51と、述語Aおよび述語Bの内容が異なることを除いてソースコード51と同一である。すなわち、ここでは、述語Aが「x>1」であり、述語Bが「0<x−1」である。   FIG. 5 is a diagram illustrating a specific example of a test case generated by the test case generation apparatus 10. The source code 52 shown in FIG. 5 is the same as the source code 51 shown in FIG. 4 except that the contents of the predicates A and B are different. That is, here, the predicate A is “x> 1” and the predicate B is “0 <x−1”.

テストケース生成装置10は、図3に示した動作と同様の動作を行う。すなわち、パス解析部12は、入力部11からソースコード52を取得し、そのソースコード52からパスを抽出すると共に、抽出したパスをパス解析結果記憶部15に保存する。ここでは、パス解析部12は第1の実施形態と同一のパス1−4を抽出する。   The test case generation device 10 performs an operation similar to the operation illustrated in FIG. That is, the path analysis unit 12 acquires the source code 52 from the input unit 11, extracts a path from the source code 52, and stores the extracted path in the path analysis result storage unit 15. Here, the path analysis unit 12 extracts the same path 1-4 as in the first embodiment.

続いて、パス解析部12は、抽出したパスから述語を抽出すると共に、抽出した述語をパス解析結果記憶部15に保存する。ここでは、パス解析部12は、述語Aとして「x>1」、述語Bとして「0<x−1」を抽出し、これらをパス解析結果記憶部15に保存する。   Subsequently, the path analysis unit 12 extracts a predicate from the extracted path and stores the extracted predicate in the path analysis result storage unit 15. Here, the path analysis unit 12 extracts “x> 1” as the predicate A and “0 <x−1” as the predicate B, and stores them in the path analysis result storage unit 15.

続いて、述語正規化部13は、パス解析部12により保存された述語を正規化すると共に、その結果をパス解析結果記憶部15に保存する。すなわち、述語正規化部13は、述語Aを「x>1」、述語Bを「x>1」のように、それぞれ正規化すると共に、述語Aと述語Bとが等価であることを認識する。そして、述語正規化部13は正規化した結果と、述語Aと述語Bとが等価であることとを、パス解析結果記憶部15に保存する。   Subsequently, the predicate normalization unit 13 normalizes the predicate stored by the path analysis unit 12 and stores the result in the path analysis result storage unit 15. That is, the predicate normalization unit 13 normalizes the predicate A such as “x> 1” and the predicate B such that “x> 1”, and recognizes that the predicate A and the predicate B are equivalent. . Then, the predicate normalization unit 13 saves the normalized result and the predicate A and the predicate B are equivalent in the path analysis result storage unit 15.

続いて、実行可能性判定部14は、パス解析結果記憶部15に格納される正規化された述語に基づいて、パスが実行可能かどうかを判定し、判定結果を出力部16に出力する。   Subsequently, the feasibility determination unit 14 determines whether or not the path is executable based on the normalized predicate stored in the path analysis result storage unit 15, and outputs the determination result to the output unit 16.

ここでは、第1の実施形態と同様に、述語Aと述語Bは等価である。よって、「述語Aが真」かつ「述語Bが偽」、および「述語Aが偽」かつ「述語Bが真」というケースは、成り立たない。したがって、実行可能性判定部14は、第1の実施形態と同様に、そのような条件を含むパスを実行不可能パスであると判断すると共に、該パスを、パス解析結果記憶部15に保存したパスの集合から除外したものを、テストケースとして出力部16に出力する。すなわち、実行可能性判定部14は、パス2およびパス3をパスの集合から除外したパス1およびパス4を、テストケースとして出力部16に出力する。   Here, as in the first embodiment, predicate A and predicate B are equivalent. Therefore, the cases where “predicate A is true” and “predicate B is false” and “predicate A is false” and “predicate B is true” are not satisfied. Therefore, the feasibility determination unit 14 determines that a path including such a condition is an infeasible path and saves the path in the path analysis result storage unit 15 as in the first embodiment. Those excluded from the set of paths are output to the output unit 16 as test cases. That is, the feasibility determination unit 14 outputs the path 1 and the path 4 obtained by excluding the path 2 and the path 3 from the set of paths to the output unit 16 as a test case.

以上のように、この第2の実施形態によれば、上記第1の実施形態と同様に、テストケース生成装置10のパス解析部12が、ソースコードからパスを抽出すると共に、抽出したパスから述語を抽出し、述語正規化部13が、抽出した述語を正規化する。そして、実行可能性判定部14が、正規化された述語に基づいて、パスが実行可能か否かを判定する。実行可能性判定部14は、実行不可能なパスを除外したパスの集合を、テストケースとして出力する。本実施形態は上記構成を有するので、テスト実施者がテストを実施する前にテストケースが実行可能であるかどうかを判断することが不要になるという効果が得られる。また、テストケースから実行不可能なパスを除外できるため、テストケース数が少なくなり、ソースコードが表すコンピュータプログラムのテスト効率を向上することができるという効果が得られる。   As described above, according to the second embodiment, as in the first embodiment, the path analysis unit 12 of the test case generation device 10 extracts a path from the source code and extracts the path from the extracted path. The predicate is extracted, and the predicate normalization unit 13 normalizes the extracted predicate. Then, the feasibility determination unit 14 determines whether or not the path is executable based on the normalized predicate. The feasibility determination unit 14 outputs a set of paths excluding non-executable paths as a test case. Since the present embodiment has the above-described configuration, it is possible to obtain an effect that it is not necessary for the tester to determine whether the test case can be executed before the test is performed. In addition, since it is possible to exclude non-executable paths from the test cases, the number of test cases is reduced, and the test efficiency of the computer program represented by the source code can be improved.

第3の実施形態
第3の実施形態では、上記第1の実施形態において説明したテストケース生成装置10によりテストケースを生成する別の例について説明する。
Third Embodiment In the third embodiment, another example in which a test case is generated by the test case generation apparatus 10 described in the first embodiment will be described.

図6は、テストケース生成装置10により生成されるテストケースの具体例を示す図である。図6に示すソースコード53は、図4に示したソースコード51と、述語Aおよび述語Bの内容が異なることを除いてソースコード51と同一である。すなわち、ここでは、述語Aがx>0であり、述語Bがx<=0である。   FIG. 6 is a diagram illustrating a specific example of a test case generated by the test case generation apparatus 10. The source code 53 shown in FIG. 6 is the same as the source code 51 except that the contents of the predicate A and the predicate B are different from the source code 51 shown in FIG. That is, here, the predicate A is x> 0 and the predicate B is x <= 0.

テストケース生成装置10は、図3に示した動作と同様の動作を行う。すなわち、パス解析部12は、入力部11からソースコード52を取得し、そのソースコード52からパスを抽出すると共に、抽出したパスをパス解析結果記憶部15に保存する。ここでは、パス解析部12は第1の実施形態と同一のパス1−4を抽出する。   The test case generation device 10 performs an operation similar to the operation illustrated in FIG. That is, the path analysis unit 12 acquires the source code 52 from the input unit 11, extracts a path from the source code 52, and stores the extracted path in the path analysis result storage unit 15. Here, the path analysis unit 12 extracts the same path 1-4 as in the first embodiment.

続いて、パス解析部12は、抽出したパスから述語を抽出すると共に、抽出した述語をパス解析結果記憶部15に保存する。ここでは、パス解析部12は、述語Aとしてx>0、述語Bとしてx<=0を抽出し、これらをパス解析結果記憶部15に保存する。   Subsequently, the path analysis unit 12 extracts a predicate from the extracted path and stores the extracted predicate in the path analysis result storage unit 15. Here, the path analysis unit 12 extracts x> 0 as the predicate A and x <= 0 as the predicate B, and stores them in the path analysis result storage unit 15.

続いて、述語正規化部13は、パス解析部12により保存された述語を正規化すると共に、その結果をパス解析結果記憶部15に保存する。すなわち、述語正規化部13は、述語Aを「x>0」、述語Bを「x<=0」のように、それぞれ正規化すると共に、述語Aの否定と述語Bとが等価であることを認識する。そして、述語正規化部13は正規化した結果と、述語Aの否定と述語Bとが等価であることとを、パス解析結果記憶部15に保存する。   Subsequently, the predicate normalization unit 13 normalizes the predicate stored by the path analysis unit 12 and stores the result in the path analysis result storage unit 15. That is, the predicate normalization unit 13 normalizes the predicate A as “x> 0” and the predicate B as “x <= 0”, respectively, and the negation of the predicate A is equivalent to the predicate B. Recognize Then, the predicate normalization unit 13 stores in the path analysis result storage unit 15 the normalized result and the negation of the predicate A and the predicate B are equivalent.

続いて、実行可能性判定部14は、パス解析結果記憶部15に格納される正規化された述語に基づいて、パスが実行可能かどうかを判定し、判定結果を出力部16に出力する。   Subsequently, the feasibility determination unit 14 determines whether or not the path is executable based on the normalized predicate stored in the path analysis result storage unit 15, and outputs the determination result to the output unit 16.

ここでは、述語Aの否定と述語Bとが等価である。よって、述語Aと述語Bとは互いに排反であるので、「述語Aが真」かつ「述語Bが真」、および「述語Aが偽」かつ「述語Bが偽」というケースは、成り立たない。したがって、実行可能性判定部14は、そのような条件を含むパスを実行不可能パスであると判断すると共に、該パスを、パス解析結果記憶部15に保存したパスの集合から除外したものを、テストケースとして出力部16に出力する。すなわち、実行可能性判定部14は、パス1およびパス4をパスの集合から除外したパス2およびパス3を、テストケースとして出力部16に出力する。   Here, the negation of predicate A and predicate B are equivalent. Thus, since predicate A and predicate B are mutually exclusive, the cases where “predicate A is true” and “predicate B is true” and “predicate A is false” and “predicate B is false” do not hold. . Therefore, the feasibility determination unit 14 determines that a path including such a condition is an infeasible path, and excludes the path from the set of paths stored in the path analysis result storage unit 15. The result is output to the output unit 16 as a test case. That is, the feasibility determination unit 14 outputs the path 2 and the path 3 obtained by excluding the path 1 and the path 4 from the set of paths to the output unit 16 as a test case.

以上のように、この第3の実施形態によれば、上記第1の実施形態と同様に、テストケース生成装置10のパス解析部12が、ソースコードからパスを抽出すると共に、抽出したパスから述語を抽出し、述語正規化部13が、抽出した述語を正規化する。そして、実行可能性判定部14が、正規化された述語に基づいて、パスが実行可能か否かを判定する。実行可能性判定部14は、実行不可能なパスを除外したパスの集合を、テストケースとして出力する。本実施形態は上記構成を有するので、テスト実施者がテストを実施する前にテストケースが実行可能であるかどうかを判断することが不要になるという効果が得られる。また、テストケースから実行不可能なパスを除外できるため、テストケース数が少なくなり、ソースコードが表すコンピュータプログラムのテスト効率を向上することができるという効果が得られる。   As described above, according to the third embodiment, as in the first embodiment, the path analysis unit 12 of the test case generation device 10 extracts a path from the source code, and from the extracted path. The predicate is extracted, and the predicate normalization unit 13 normalizes the extracted predicate. Then, the feasibility determination unit 14 determines whether or not the path is executable based on the normalized predicate. The feasibility determination unit 14 outputs a set of paths excluding non-executable paths as a test case. Since the present embodiment has the above-described configuration, it is possible to obtain an effect that it is not necessary for the tester to determine whether the test case can be executed before the test is performed. In addition, since it is possible to exclude non-executable paths from the test cases, the number of test cases is reduced, and the test efficiency of the computer program represented by the source code can be improved.

第4の実施形態
図7は、本発明の第4の実施形態に係るテストケース生成装置60の構成を示すブロック図である。図7に示すように、テストケース生成装置60は、抽出部61および判定部62を備える。
Fourth Embodiment FIG. 7 is a block diagram showing a configuration of a test case generation device 60 according to a fourth embodiment of the present invention. As shown in FIG. 7, the test case generation device 60 includes an extraction unit 61 and a determination unit 62.

抽出部61は、入力されたソースコードから、そのソースコードが表すコンピュータプログラムが実行されたときの流れを示すパスをテストケースとして抽出すると共に、該抽出したパスに含まれる判断条件を抽出する。判定部62は、抽出された判断条件に基づいて、パスが実行可能であるか否かを判定し、実行可能でないと判定された場合、該パスをテストケースから除外する。   The extraction unit 61 extracts, from the input source code, a path indicating a flow when the computer program represented by the source code is executed as a test case, and extracts a determination condition included in the extracted path. The determination unit 62 determines whether or not the path is executable based on the extracted determination condition. If it is determined that the path is not executable, the path is excluded from the test case.

抽出部61は、第1の実施形態のパス解析部12に相当し、判定部62は、第1の実施形態の述語正規化部13および実行可能性判定部14に相当する。   The extraction unit 61 corresponds to the path analysis unit 12 of the first embodiment, and the determination unit 62 corresponds to the predicate normalization unit 13 and the feasibility determination unit 14 of the first embodiment.

以上のように、第4の実施形態によれば、テストケース生成装置60は上記構成を有するので、ソースコードが表すコンピュータプログラムのテスト効率を向上することができるという効果が得られる。   As described above, according to the fourth embodiment, since the test case generation device 60 has the above configuration, it is possible to improve the test efficiency of the computer program represented by the source code.

本発明は、例えばソフトウェア開発におけるテストにおいてテストケースを生成するテストケース生成装置、テストケース生成装置をコンピュータに実現するためのプログラムといった用途に適用できる。また、テストケースを生成する機能を、ハードウエア開発におけるハードウエアに対するテストケース生成機能や、モデルベース開発におけるモデルに対するテストケース生成機能や、ビジネスロジックやビジネスプロセス等の論理記述言語に対するテストケース生成機能にも適用できる。   The present invention can be applied to uses such as a test case generation apparatus that generates a test case in a test in software development, and a program for realizing the test case generation apparatus on a computer. The test case generation function includes the test case generation function for hardware in hardware development, the test case generation function for models in model-based development, and the test case generation function for logical description languages such as business logic and business processes. It can also be applied to.

10 テストケース生成装置
11 入力部
12 パス解析部
13 述語正規化部
14 実行可能性判定部
15 パス解析結果記憶部
16 出力部
20 ソースコード記憶部
30 テストケース記憶部
40 CPU
41 記憶媒体
42 プログラム
60 テストケース生成装置
61 抽出部
62 判定部
DESCRIPTION OF SYMBOLS 10 Test case production | generation apparatus 11 Input part 12 Path analysis part 13 Predicate normalization part 14 Executability determination part 15 Path analysis result memory | storage part 16 Output part 20 Source code memory | storage part 30 Test case memory | storage part 40 CPU
41 Storage Medium 42 Program 60 Test Case Generation Device 61 Extraction Unit 62 Determination Unit

Claims (3)

入力されたソースコードから、そのソースコードが表すコンピュータプログラムが実行されたときの流れを示すパスをテストケースとして抽出すると共に、該抽出したパスに含まれる判断条件を抽出する抽出手段と、
前記抽出手段により抽出された判断条件を正規化する正規化手段と、
前記正規化手段により正規化された判断条件に基づいて、前記パスが実行可能であるか否かを判定し、実行可能でないと判定された場合、該パスを前記テストケースから除外する判定手段と
を備え
前記判定手段は、前記正規化手段により正規化された複数の判断条件を含むパスのうち、当該複数の判断条件が互いに等価である場合に成立しないパス、および当該複数の判断条件が互いに排反する場合に成立しないパスを、実行可能でないと判定し、前記テストケースから除外するテストケース生成装置。
An extraction means for extracting, as a test case, a path indicating a flow when the computer program represented by the source code is executed from the input source code, and extracting a determination condition included in the extracted path;
Normalizing means for normalizing the judgment condition extracted by the extracting means;
A determination unit that determines whether or not the path is executable based on the determination condition normalized by the normalization unit; and when the path is determined not to be executable, a determination unit that excludes the path from the test case; equipped with a,
The determination unit includes a plurality of determination conditions normalized by the normalization unit, a path that does not hold when the plurality of determination conditions are equivalent to each other, and the plurality of determination conditions are mutually exclusive. A test case generation device that determines that a path that does not hold in the case is not executable and excludes the path from the test case.
入力されたソースコードから、そのソースコードが表すコンピュータプログラムが実行されたときの流れを示すパスをテストケースとして抽出すると共に、該抽出したパスに含まれる判断条件を抽出し、From the input source code, a path indicating a flow when the computer program represented by the source code is executed is extracted as a test case, and a determination condition included in the extracted path is extracted.
前記抽出された判断条件を正規化し、  Normalizing the extracted judgment condition;
前記正規化された判断条件に基づいて、前記パスが実行可能であるか否かを判定し、実行可能でないと判定された場合、該パスを前記テストケースから除外し、  Based on the normalized determination condition, determine whether or not the path is executable, and if it is determined that the path is not executable, exclude the path from the test case,
前記パスが実行可能であるか否かの判定にあたり、前記正規化された複数の判断条件を含むパスのうち、当該複数の判断条件が互いに等価である場合に成立しないパス、および当該複数の判断条件が互いに排反する場合に成立しないパスを、実行可能でないと判定し、前記テストケースから除外するテストケース生成方法。  In determining whether the path can be executed, among the paths including the plurality of normalized determination conditions, a path that is not satisfied when the plurality of determination conditions are equivalent to each other, and the plurality of determinations A test case generation method that determines that a path that does not hold when the conditions are mutually exclusive is not executable and excludes the path from the test case.
入力されたソースコードから、そのソースコードが表すコンピュータプログラムが実行されたときの流れを示すパスをテストケースとして抽出すると共に、該抽出したパスに含まれる判断条件を抽出する抽出処理と、An extraction process for extracting a path indicating a flow when the computer program represented by the source code is executed as a test case from the input source code, and extracting a determination condition included in the extracted path;
前記抽出された判断条件を正規化する正規化処理と、  Normalization processing for normalizing the extracted judgment condition;
前記正規化された判断条件に基づいて、前記パスが実行可能であるか否かを判定し、実行可能でないと判定された場合、該パスを前記テストケースから除外する判定処理と、  Based on the normalized determination condition, it is determined whether or not the path is executable, and when it is determined that the path is not executable, a determination process of excluding the path from the test case;
前記判定処理において、前記正規化された複数の判断条件を含むパスのうち、当該複数の判断条件が互いに等価である場合に成立しないパス、および当該複数の判断条件が互いに排反する場合に成立しないパスを、実行可能でないと判定し、前記テストケースから除外する処理を、コンピュータに実行させるテストケース生成プログラム。  In the determination process, among the paths including the plurality of normalized determination conditions, a path that is not satisfied when the plurality of determination conditions are equivalent to each other, and a path that is not satisfied when the plurality of determination conditions are mutually exclusive A test case generation program for causing a computer to execute a process of determining that a pass is not executable and excluding it from the test case.
JP2010204439A 2010-09-13 2010-09-13 Test case generation apparatus, test case generation method, and test case generation program Active JP5755861B2 (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
JP2010204439A JP5755861B2 (en) 2010-09-13 2010-09-13 Test case generation apparatus, test case generation method, and test case generation program

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
JP2010204439A JP5755861B2 (en) 2010-09-13 2010-09-13 Test case generation apparatus, test case generation method, and test case generation program

Publications (2)

Publication Number Publication Date
JP2012059202A JP2012059202A (en) 2012-03-22
JP5755861B2 true JP5755861B2 (en) 2015-07-29

Family

ID=46056184

Family Applications (1)

Application Number Title Priority Date Filing Date
JP2010204439A Active JP5755861B2 (en) 2010-09-13 2010-09-13 Test case generation apparatus, test case generation method, and test case generation program

Country Status (1)

Country Link
JP (1) JP5755861B2 (en)

Families Citing this family (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JP5900197B2 (en) * 2012-01-31 2016-04-06 富士通株式会社 Route condition selection apparatus, program, and method
JP5900212B2 (en) * 2012-07-18 2016-04-06 富士通株式会社 Test data generation apparatus, program, and method

Family Cites Families (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JPH04260941A (en) * 1991-01-25 1992-09-16 Mitsubishi Electric Corp Automatic formation device for test data
JPH04271440A (en) * 1991-02-27 1992-09-28 Hitachi Ltd System for automatically preparing test item
JP2000347900A (en) * 1999-06-02 2000-12-15 Fujitsu Ltd Input parameter generating device and method, and recording medium

Also Published As

Publication number Publication date
JP2012059202A (en) 2012-03-22

Similar Documents

Publication Publication Date Title
JP6607565B2 (en) Integrated automated test case generation for safety critical software
US20090319829A1 (en) Pattern extraction method and apparatus
JP2016115175A (en) Software test apparatus and software test program
JP2008191963A (en) Source code verification system, source code verification method and source code verification program
JP6559600B2 (en) Information processing apparatus, information processing program, and inspection system
US20150220733A1 (en) Apparatus and method for detecting a malicious code based on collecting event information
JP5755861B2 (en) Test case generation apparatus, test case generation method, and test case generation program
JP2012181666A (en) Information processing device, information processing method and information processing program
JP6903249B2 (en) Test case generator, test case generator, and test case generator
JP6790921B2 (en) Program analyzer, program analysis method and program analysis program
JP6107455B2 (en) Test schedule determination device and program
JP2009134360A (en) Model inspection system, model inspection method, and model inspection program
WO2012049816A1 (en) Model checking device, method, and program
JP6723483B2 (en) Test case generation device, test case generation method, and test case generation program
JP6878707B2 (en) Test equipment, test methods and test programs
JP2017151594A (en) Supporting device, supporting method, and program
JP5516277B2 (en) Test case relation extraction method, test case relation extraction device, and test case relation extraction program
JP6362970B2 (en) Compiling method, compiling device, and compiler program
US11907710B2 (en) Source code analysis apparatus
JP7059827B2 (en) Source code generator
JP2018147114A (en) Test case generation method, computer, and program
JP5233354B2 (en) Property verification system, property verification method, and program
JP2008262473A (en) Equipment maintenance management system
JP2013061893A (en) Information processor, information processing method, and program
JP2014115960A (en) Verification device, verification method, and verification program

Legal Events

Date Code Title Description
A621 Written request for application examination

Free format text: JAPANESE INTERMEDIATE CODE: A621

Effective date: 20130815

A977 Report on retrieval

Free format text: JAPANESE INTERMEDIATE CODE: A971007

Effective date: 20140520

A131 Notification of reasons for refusal

Free format text: JAPANESE INTERMEDIATE CODE: A131

Effective date: 20140603

A521 Written amendment

Free format text: JAPANESE INTERMEDIATE CODE: A523

Effective date: 20140723

A131 Notification of reasons for refusal

Free format text: JAPANESE INTERMEDIATE CODE: A131

Effective date: 20140930

A521 Written amendment

Free format text: JAPANESE INTERMEDIATE CODE: A523

Effective date: 20141106

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: 20150507

A61 First payment of annual fees (during grant procedure)

Free format text: JAPANESE INTERMEDIATE CODE: A61

Effective date: 20150528

R150 Certificate of patent or registration of utility model

Ref document number: 5755861

Country of ref document: JP

Free format text: JAPANESE INTERMEDIATE CODE: R150