JP2011100420A - Test program creation device - Google Patents

Test program creation device Download PDF

Info

Publication number
JP2011100420A
JP2011100420A JP2009256483A JP2009256483A JP2011100420A JP 2011100420 A JP2011100420 A JP 2011100420A JP 2009256483 A JP2009256483 A JP 2009256483A JP 2009256483 A JP2009256483 A JP 2009256483A JP 2011100420 A JP2011100420 A JP 2011100420A
Authority
JP
Japan
Prior art keywords
test
test program
program
program creation
data
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.)
Pending
Application number
JP2009256483A
Other languages
Japanese (ja)
Inventor
Takayuki Hitomi
隆行 人見
Haruhiko Iida
晴彦 飯田
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.)
Toshiba Corp
Toshiba Digital Solutions Corp
Original Assignee
Toshiba Corp
Toshiba Solutions Corp
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 Toshiba Corp, Toshiba Solutions Corp filed Critical Toshiba Corp
Priority to JP2009256483A priority Critical patent/JP2011100420A/en
Priority to CN2010105365795A priority patent/CN102053909A/en
Publication of JP2011100420A publication Critical patent/JP2011100420A/en
Pending legal-status Critical Current

Links

Images

Abstract

<P>PROBLEM TO BE SOLVED: To provide a test program creation device creating a test program for testing a program receiving a structure group having a hierarchical structure and operating, for example. <P>SOLUTION: Test data definition data 21 input in a unit test program creation system 1 is recorded by XML (extensible markup language), and the hierarchical structure of the structure group supplied to a test target program is represented by a previously defined tag. A test program creation part 11 recognizes the hierarchical structure of the structure group received by a method of a test target and each value of a parameter inside the structure group based on the tag, and creates and outputs the test program 22 having a procedure of generating the structure group having the values and a procedure of calling the method of the test target with a structure positioned in the topmost position as an argument. <P>COPYRIGHT: (C)2011,JPO&INPIT

Description

この発明は、例えばプログラムの単体テストに用いるテストプログラムの作成作業を支援するためのシステム開発支援技術に関する。   The present invention relates to a system development support technology for supporting, for example, the creation of a test program used for a unit test of a program.

近年、様々な業種で作業の電子化が広く図られている。また、インターネットの利用が一般化した今日では、取引の形態が多様化し、かつ、その変貌も著しい。そのため、このような状況に即時に対応するためのシステム開発の効率化が、以前にも増して強く要求されてきている。そして、その方策の1つとして、プログラムのテストを効率的に行うための仕組みが、これまでも種々提案されている(例えば特許文献1,2等参照)。   In recent years, computerization of work has been widely promoted in various industries. In addition, today, when the use of the Internet has become commonplace, the form of transactions has diversified and its transformation has been remarkable. For this reason, there has been a strong demand for more efficient system development to respond immediately to such a situation. As one of the measures, various mechanisms for efficiently testing a program have been proposed (see, for example, Patent Documents 1 and 2).

特開2009−32133号公報JP 2009-32133 A 特開2008−140263号公報JP 2008-140263 A

ここで、開発中のプログラムについて、メソッド(関数、サブルーチン等)単位のテストを行う場合を考える。そして、このメソッドの中に、階層構造を持つ構造体(オブジェクトやデータ)群を受け取って動作するものが存在するものと想定する。この場合、そのメソッドは、最上位に位置する構造体を引数として受け取って動作を開始する。   Here, consider a case in which a method (function, subroutine, etc.) unit test is performed on a program under development. It is assumed that there are some methods that operate by receiving a group of structures (objects and data) having a hierarchical structure. In this case, the method starts operation by receiving the structure located at the top as an argument.

しかしながら、これまでは、メソッドに引数として直接的に引き渡す値を設定してテストを行うための支援ツールは種々存在したものの、階層構造を持つ構造体群を受け取って動作するメソッドについて、最上位に位置する構造体に加えて、次位層以下に位置する構造体の値をも設定してテストを行うための支援ツールは存在せず、意図したテストを簡単には行えないのが実情であった。   However, until now, there are various support tools for testing by setting the value passed directly as an argument to the method, but the method that receives and operates the hierarchical structure group is the highest level. There is no support tool for testing by setting the value of the structure located below the next layer in addition to the located structure, and the actual situation is that the intended test cannot be performed easily. It was.

この発明は、このような事情を考慮してなされたものであり、例えば、階層構造を持つ構造体群を受け取って動作するプログラムをテストするためのテストプログラムを簡単に作成することを可能とするテストプログラム作成装置を提供することを目的とする。   The present invention has been made in view of such circumstances. For example, it is possible to easily create a test program for testing a program that operates by receiving a structure group having a hierarchical structure. An object is to provide a test program creation device.

前述の課題を解決するために、この発明のテストプログラム作成装置は、階層構造を持つ構造体群の最上位に位置する構造体を引数として受け取って動作するプログラムをテストするためのテストプログラムを作成するテストプログラム作成装置であって、前記階層構造を持つ構造体群の各値を定義するテストデータ定義データを入力する入力手段と、前記入力手段により入力されたテストデータ定義データで定義される各値を持つ前記階層構造を持つ構造体群を生成する手続きと、当該生成した構造体群の最上位に位置する構造体を引数としてテスト対象の前記プログラムを呼び出す手続きとを有する前記テストプログラムを作成するテストプログラム作成手段と、を具備することを特徴とする。   In order to solve the above-described problems, the test program creation device of the present invention creates a test program for testing a program that operates by receiving a structure located at the top of a structure group having a hierarchical structure as an argument. A test program creation device for inputting test data definition data for defining each value of a group of structures having a hierarchical structure, and each defined by test data definition data input by the input means Creating the test program having a procedure for generating a structure group having a hierarchical structure having a value and a procedure for calling the program to be tested with a structure positioned at the top of the generated structure group as an argument And a test program creating means.

この発明によれば、例えば、階層構造を持つ構造体群を受け取って動作するプログラムをテストするためのテストプログラムを簡単に作成することが可能となる。   According to the present invention, for example, it is possible to easily create a test program for testing a program that operates by receiving a structure group having a hierarchical structure.

この発明の第1実施形態に係るテストプログラム作成装置(単体テストプログラム作成システム)の機能ブロック図。1 is a functional block diagram of a test program creation device (unit test program creation system) according to a first embodiment of the present invention. 同第1実施形態の単体テストプログラム作成システムにおける単体テスト対象プログラム(メソッド)の一例を示す図。The figure which shows an example of the unit test object program (method) in the unit test program creation system of the said 1st Embodiment. 同第1実施形態の単体テストプログラム作成システムで用いられるテストデータ定義データの一例を示す第1の図。The 1st figure which shows an example of the test data definition data used with the unit test program creation system of the said 1st Embodiment. 同第1実施形態の単体テストプログラム作成システムによって作成されるテストプログラムの一例を示す第1の図。FIG. 3 is a first diagram showing an example of a test program created by the unit test program creation system of the first embodiment. 同第1実施形態の単体テストプログラム作成システムで用いられるテストデータ定義データの一例を示す第2の図。The 2nd figure which shows an example of the test data definition data used with the unit test program creation system of the said 1st Embodiment. 同第1実施形態の単体テストプログラム作成システムによって作成されるテストプログラムの一例を示す第2の図。The 2nd figure which shows an example of the test program produced by the unit test program production system of the said 1st Embodiment. 同第2実施形態の単体テストプログラム作成システムで用いられるテストデータ定義データの一例を示す図。The figure which shows an example of the test data definition data used with the unit test program creation system of the said 2nd Embodiment. 同第3実施形態に係るテストプログラム作成装置(単体テストプログラム作成システム)の機能ブロック図。The functional block diagram of the test program creation apparatus (unit test program creation system) concerning the 3rd embodiment. 同第3実施形態の単体テストプログラム作成システムで用いられるソースコードの一部の一例を示す図。The figure which shows an example of a part of source code used with the unit test program creation system of the said 3rd Embodiment. 同第3実施形態の単体テストプログラム作成システムにおいてコメントとして用いるタグの一例を示す図。The figure which shows an example of the tag used as a comment in the unit test program creation system of the said 3rd Embodiment. 同第3実施形態の単体テストプログラム作成システムにおいてコメントとして用いる演算子の一例を示す図。The figure which shows an example of the operator used as a comment in the unit test program creation system of the said 3rd Embodiment. 同第4実施形態の単体テストプログラム作成システムで用いられるソースコードの一部の一例を示す図。The figure which shows an example of a part of source code used with the unit test program creation system of the said 4th Embodiment. 同第4実施形態の単体テストプログラム作成システムによってテストプログラムが作成される原理を説明するための図。The figure for demonstrating the principle in which a test program is produced by the unit test program production system of the said 4th Embodiment.

以下、図面を参照して、この発明の実施形態を説明する。   Embodiments of the present invention will be described below with reference to the drawings.

(第1実施形態)
まず、この発明の第1実施形態について説明する。
(First embodiment)
First, a first embodiment of the present invention will be described.

図1は、第1実施形態に係るテストプログラム作成装置(単体テストプログラム作成システム1)の機能ブロック図である。この単体テストプログラム作成システム1は、例えば、CD(conpact disc)等のコンピュータ読取り可能な記憶メディアに記録されて頒布される単体テストプログラム作成プログラムが、パーソナルコンピュータのHD(hard disc)にインストールされ、主メモリにロードされてCPU(central processing unit)によって実行されることによって、そのパーソナルコンピュータ上に構築されるものである。   FIG. 1 is a functional block diagram of a test program creation device (unit test program creation system 1) according to the first embodiment. In this unit test program creation system 1, for example, a unit test program creation program recorded in a computer-readable storage medium such as a CD (conpact disc) and distributed is installed on an HD (hard disc) of a personal computer, and the main memory It is built on the personal computer by being loaded on and executed by a central processing unit (CPU).

この単体テストプログラム作成システム1は、例えば、階層的に構造化されたデータ群を受け取って動作するプログラム(メソッド等)について、引数として直接的に引き渡す最上位に位置するデータの値だけでなく、次位以下に位置するデータ群の値をも設定してテストを行うためのテストプログラムを作成するものであり、図1に示すように、テストプログラム作成部11を有している。   For example, the unit test program creation system 1 receives not only the value of the data located at the highest level to be directly passed as an argument for a program (method or the like) that operates by receiving a hierarchically structured data group. A test program for creating a test by setting a value of a data group located below the order is created, and has a test program creation unit 11 as shown in FIG.

テストプログラム作成部11は、テストデータ定義データ21を入力して、単体テスト対象のプログラムをテストするためのテストプログラム22を作成する。図2に、単体テスト対象プログラムの一例を示す。   The test program creation unit 11 receives the test data definition data 21 and creates a test program 22 for testing the unit test target program. FIG. 2 shows an example of the unit test target program.

ここでは、"testMethod"というメソッドが、単体テスト対象プログラムであるものと想定する。図2に示すように、このメソッド"testMethod"は、引数として、"box"という構造体を受け取って動作する。この構造体"box"は、"num"、"id"、"area"という3つのパラメータで構成されている。そして、その3つのパラメータのうちのパラメータ"area"は、別途定義される、パラメータ"count"を有する構造体となっている。つまり、メソッド"testMethod"は、階層構造を持つ構造体群("box","area")を受け取って動作するメソッドであって、最上位に位置する構造体"box"のみを引数として直接的に受け取るメソッドである。そして、この単体テストプログラム作成システム1は、引数として直接的に受け渡しが行われる構造体"box"だけでなく、構造体"area"についても、目的の値を設定した上で、メソッド"testMethod"を動作させるテストプログラム22を簡単に作成できるようにしたものであり、以下、この点について詳述する。   Here, it is assumed that the method "testMethod" is a unit test target program. As shown in FIG. 2, the method “testMethod” operates by receiving a structure “box” as an argument. This structure “box” is composed of three parameters “num”, “id”, and “area”. Of the three parameters, the parameter “area” is a structure having a parameter “count” defined separately. In other words, the method "testMethod" is a method that operates by receiving a structure group ("box", "area") having a hierarchical structure, and only the structure "box" positioned at the top is directly used as an argument. It is a method received in The unit test program creation system 1 sets a target value not only for the structure “box” that is directly passed as an argument but also for the structure “area”, and then sets the method “testMethod”. The test program 22 to be operated can be easily created, and this will be described in detail below.

図3は、テストデータ定義データ21の一例を示す図である。ここでは、図2に示したメソッド"testMethod"を、構造体"box"のパラメータ"num","id"に"10","A"を設定すると共に、(構造体"box"の一パラメータとして当該構造体"box"の下位層に位置づけられる)構造体"area"のパラメータ"count"に"1"を設定した上で動作させるためのテストプログラム22を作成する場合を想定する。   FIG. 3 is a diagram illustrating an example of the test data definition data 21. Here, the method “testMethod” shown in FIG. 2 is set to the parameters “num” and “id” of the structure “box”, and “10” and “A” are set (one parameter of the structure “box”). Assume that the test program 22 is created to operate with the parameter “count” of the structure “area” set to “1” (positioned as a lower layer of the structure “box”).

図3に示すように、テストデータ定義データ21は、XML(extensible markup language)によって記載されるテキストデータである。XMLは、タグをユーザが自由に定義することのできる記述言語である。そこで、この単体テストプログラム作成システム1では、予め定義したタグを使用することによって、テスト対象プログラムに供給する構造体群の階層構造をテストデータ定義データ21上において表現する。なお、図3に示したテストデータ定義データ21内に埋め込まれたタグの名称は、単なる一例であって、これに限定されるものではなく、任意に変更(定義)することが可能である。   As shown in FIG. 3, the test data definition data 21 is text data described in XML (extensible markup language). XML is a description language in which tags can be freely defined by the user. Therefore, in the unit test program creation system 1, the hierarchical structure of the structure group supplied to the test target program is expressed on the test data definition data 21 by using a predefined tag. The name of the tag embedded in the test data definition data 21 shown in FIG. 3 is merely an example, and is not limited to this, and can be arbitrarily changed (defined).

より具体的に説明すると、図3に示したテストデータ定義データ21を入力したテストプログラム作成部11は、タグに基づき、まず、(1-1)構造体"box"が引数であること(図3のa1)および(1-2)構造体"box"にはパラメータ"num","id","area"が存在し、かつ、パラメータ"area"は構造体であること(図3のa11,a12,a13)、つまり、構造体群の階層構造を認識する。   More specifically, the test program creation unit 11 that has input the test data definition data 21 shown in FIG. 3 starts with (1-1) the structure “box” as an argument based on the tag (see FIG. 3) a1) and (1-2) The parameter “num”, “id”, “area” exists in the structure “box”, and the parameter “area” is a structure (a11 in FIG. 3). , A12, a13), that is, the hierarchical structure of the structure group is recognized.

また、テストプログラム作成部11は、タグに基づき、(2-1)パラメータ"num"に"10"を設定すること(図3のa11)、(2-2)パラメータ"id"に"A"を設定すること(図3のa11)および(2-3)パラメータ"area"(構造体)内のパラメータ"count"に"1"を設定すること(図3のa13)、つまり、構造体群中のパラメータの各値を認識する。   Also, the test program creation unit 11 sets (2-1) parameter “num” to “10” (a11 in FIG. 3) and (2-2) parameter “id” based on the tag. (A3 in FIG. 3) and (2-3) setting “1” to the parameter “count” in the parameter “area” (structure) (a13 in FIG. 3), that is, the structure group Recognize each value of the parameter inside.

そして、テストプログラム作成部11は、パラメータ"num"に"10"、パラメータ"id"に"A"が設定された構造体"box"とパラメータ"count"に"1"が設定された構造体"area"とからなる構造体群を生成する手続きと、構造体"box"を引数としてメソッド"testMethod"を呼び出す手続きとを有するテストプログラム22を作成して出力する。図4は、この単体プログラム作成システム1によって作成されるテストプログラム22の一例を示す図である。   The test program creation unit 11 then sets the structure “box” in which the parameter “num” is set to “10”, the parameter “id” is set to “A”, and the parameter “count” is set to “1”. A test program 22 having a procedure for generating a structure group composed of “area” and a procedure for calling the method “testMethod” with the structure “box” as an argument is generated and output. FIG. 4 is a diagram showing an example of the test program 22 created by the single program creation system 1.

単体テストプログラム作成システム1は、例えば、単体テスト対象のプログラム(メソッド)名とテストデータ定義データ21のファイル名とを入力するための画面を提示するユーザインタフェース機能を有している。つまり、テスト担当者は、XMLによって記載するテキストデータであるテストデータ定義データ21を作成するだけで、階層構造を持つ構造体群を受け取って動作するプログラムについて、引数として直接的に引き渡す最上位に位置する構造体の値だけでなく、次位層以下に位置する構造体群の値をも設定してテストするためのテストプログラム22を簡単に作成することが可能となる。   The unit test program creation system 1 has a user interface function that presents a screen for inputting a unit test target program (method) name and a file name of the test data definition data 21, for example. In other words, the tester simply creates test data definition data 21 that is text data described in XML, and the program that receives and operates a structure group having a hierarchical structure is directly transferred as an argument to the highest level. It is possible to easily create a test program 22 for setting and testing not only the value of the positioned structure but also the value of the structure group positioned below the next layer.

なお、テストデータ定義データ21の取得については、各々を外部ファイルとして指定することに代えて、テストプログラム作成部11が、予め定められたデータベースにアクセスし、その時点で当該データベースに格納されたテストデータ定義データ21を順次取得していくように構成することも可能である。この場合、データベースに格納されたテストデータ定義データ21の数だけテストプログラム22が自動作成される。   As for the acquisition of the test data definition data 21, instead of specifying each as an external file, the test program creation unit 11 accesses a predetermined database, and the test data stored in the database at that time is stored. The data definition data 21 can also be configured to be acquired sequentially. In this case, as many test programs 22 as the number of test data definition data 21 stored in the database are automatically created.

また、この手法は、オブジェクトを引数として受け取って動作するプログラム(メソッド)についても有用である。いま、"Test"というオブジェクトを引数として受け取って動作するメソッド"TestMethod"を単体テスト対象プログラムとし、かつ、オブジェクト"Test"は、3つのパラメータを受け取るものであって、第2パラメータが"Test2"というオブジェクトである場合を想定する。つまり、階層構造を持つ構造体群(オブジェクト"Test","Test2")を引数とするメソッド"TestMethod"を単体テスト対象プログラムとする場合を想定する。   This method is also useful for a program (method) that operates by receiving an object as an argument. Now, a method “TestMethod” that operates by receiving an object “Test” as an argument is a unit test target program, and the object “Test” receives three parameters, and the second parameter is “Test2”. Assume that it is an object. That is, it is assumed that a method “TestMethod” having a structure group (object “Test”, “Test2”) having a hierarchical structure as an argument is a unit test target program.

この場合も、テスト担当者は、タグによって、オブジェクト"Test","Test2"の階層構造を表しつつ各パラメータの値を設定するテストデータ定義データ21を作成する。図5は、この場合のテストデータ定義データ21の一例を示す図である。   Also in this case, the person in charge of the test creates test data definition data 21 that sets the values of the respective parameters while representing the hierarchical structure of the objects “Test” and “Test2” using the tags. FIG. 5 is a diagram showing an example of the test data definition data 21 in this case.

図5に示すように、タグによって、(1-1)オブジェクト"Test"が引数であること(図5のb1)および(1-2)オブジェクト"Test"は3つのパラメータを受け取り、かつ、第2パラメータは"Test2"というオブジェクトであって、オブジェクト"Test2"は、1つのパラメータを受け取ること(図5のb1,b11,b12,b13,b121)、を表すと共に、(2-1)オブジェクト"Test"の第1,第3パラメータに"10","test"を設定すること(図5のb1,b2,b3,)および(2-2)オブジェクト"Test2"に引き渡すパラメータを"0"に設定し、かつ、その内部状態について、パラメータ"name"に"name"、データとして"10"を設定すること(図5のb121)、を表す。   As shown in FIG. 5, depending on the tag, (1-1) the object “Test” is an argument (b1 in FIG. 5) and (1-2) the object “Test” receives three parameters, and The two parameters are an object “Test2”, and the object “Test2” represents receiving one parameter (b1, b11, b12, b13, b121 in FIG. 5), and (2-1) the object “ Set “10” and “test” to the first and third parameters of “Test” (b1, b2, b3 in FIG. 5) and (2-2) set the parameter handed over to the object “Test2” to “0” For the internal state, “name” is set in the parameter “name” and “10” is set as the data (b121 in FIG. 5).

そして、この図5に示したテストデータ定義データ21を入力したテストプログラム作成部11は、各タグを解釈し、図6に示すテストプログラム22を作成して出力する。図6に示すように、テストデータ定義データ21は、設定された各値を持つオブジェクト群を生成する手続きと、生成したオブジェクト群を引数としてメソッドを呼び出す手続きとを有するテストプログラム22を作成して出力する。   5 receives the test data definition data 21 shown in FIG. 5, interprets each tag, and creates and outputs a test program 22 shown in FIG. As shown in FIG. 6, the test data definition data 21 creates a test program 22 having a procedure for generating an object group having each set value and a procedure for calling a method using the generated object group as an argument. Output.

このように、この単体テストプログラム作成システム1によれば、テスト担当者は、XMLによって記載するテキストデータであるテストデータ定義データ21を作成するだけで、オブジェクトを引数として受け取って動作するプログラムについても、引数として直接的に引き渡す最上位に位置するオブジェクトのみならず、次位層以下に位置するオブジェクトを目的の状態に設定してテストするためのテストプログラム22を簡単に作成することが可能となる。   As described above, according to the unit test program creation system 1, a tester can create a test data definition data 21 that is text data described in XML, and a program that operates by receiving an object as an argument. It is possible to easily create a test program 22 for setting and testing not only the object positioned at the highest level directly delivered as an argument, but also the objects positioned below the next layer.

(第2実施形態)
次に、この発明の第2実施形態について説明する。
(Second Embodiment)
Next explained is the second embodiment of the invention.

前述した第1実施形態の単体テストプログラム作成システム1では、テストデータ定義データ21をXMLによって記載し、その際、予め定義したタグによって、単体テスト対象プログラムに供給する構造体群の階層構造を表した。   In the unit test program creation system 1 of the first embodiment described above, the test data definition data 21 is described in XML, and the hierarchical structure of the group of structures supplied to the unit test target program is represented by a predefined tag.

これに代えて、この第2実施形態の単体テストプログラム作成システム1では、図7に示すように、インデント(字下げ)を利用して、単体テスト対象プログラムに供給する構造体群の階層構造を表す。   Instead, in the unit test program creation system 1 according to the second embodiment, as shown in FIG. 7, a hierarchical structure of a group of structures supplied to the unit test target program is represented by using indentation (indentation).

図7に示した例は、第1実施形態において説明した、階層構造を持つ構造体群(オブジェクト"Test","Test2")を引数とするメソッド"TestMethod"を単体テスト対象プログラムとする場合を想定した際に作成されるテストデータ定義データ21の一例を示す図である。   The example shown in FIG. 7 assumes that the method “TestMethod” having the structure group (objects “Test” and “Test2”) having a hierarchical structure described in the first embodiment as a unit test target program is used. It is a figure which shows an example of the test data definition data 21 produced when doing.

図7に示すように、インデントを用いることによって、(1)オブジェクト"Test"、(2)パラメータ"10","test2","test"、(3)"name","SetData"の階層構造を表現する。そして、このテストデータ定義データ21を入力したテストプログラム作成部11は、インデントに基づき、階層構造を認識して、第1実施形態と同様、図6に示したテストプログラム22を作成して出力する。   As shown in FIG. 7, by using indentation, (1) object “Test”, (2) parameters “10”, “test2”, “test”, (3) “name”, “SetData” hierarchical structure Express. Then, the test program creation unit 11 having received the test data definition data 21 recognizes the hierarchical structure based on the indentation, and creates and outputs the test program 22 shown in FIG. 6 as in the first embodiment. .

このように、この第2実施形態の単体テストプログラム作成システム1においても、テスト担当者は、インデントを適所に用いたテキストデータであるテストデータ定義データ21を作成するだけで、階層構造を持つ構造体群を受け取って動作するプログラムについて、引数として直接的に引き渡す最上位に位置する構造体の値だけでなく、次位層以下に位置する構造体群の値をも設定してテストするためのテストプログラム22を簡単に作成することが可能となる。   As described above, also in the unit test program creation system 1 of the second embodiment, the tester simply creates the test data definition data 21 that is text data using indentation in a proper position, and has a hierarchical structure. Test for setting and testing not only the value of the structure located at the highest level that is passed directly as an argument but also the value of the structure group located below the next layer for programs that operate by receiving groups The program 22 can be easily created.

(第3実施形態)
次に、この発明の第3実施形態について説明する。
(Third embodiment)
Next explained is the third embodiment of the invention.

図8は、第3実施形態に係るテストプログラム作成装置(単体テストプログラム作成システム1)の機能ブロック図である。   FIG. 8 is a functional block diagram of a test program creation device (unit test program creation system 1) according to the third embodiment.

この単体テストプログラム作成システム1は、(第1,第2実施形態において)前述したテストプログラム作成部11に加えて、ソースコード解析部12およびテストケース生成部13をさらに有している。そして、この単体テストプログラム作成システム1は、メソッド(関数,サブルーチン等)単位のテストを行おうとしているプログラムのソースコード23を入力し、このソースコード23を解析して、当該プログラム内の目的のメソッドをテストするためのテストプログラム22を作成して出力する。   The unit test program creation system 1 further includes a source code analysis unit 12 and a test case generation unit 13 in addition to the test program creation unit 11 described above (in the first and second embodiments). The unit test program creation system 1 inputs a source code 23 of a program to be tested in units of methods (functions, subroutines, etc.), analyzes the source code 23, and analyzes a target method in the program. A test program 22 for testing is generated and output.

より具体的に説明すると、この単体テストプログラム作成システム1では、ソースコード23内に、目的のメソッドに対するコメント(注釈)として、そのメソッドに与えるテストデータの範囲や値等を記載する。   More specifically, in the unit test program creation system 1, the range, value, etc. of test data given to the method are described in the source code 23 as a comment (annotation) for the target method.

図9は、ソースコード23の一部分の一例を示す図である。また、図10は、コメントとして用いるタグの一例を示す図であり、図11は、コメントとして用いる演算子の一例を示す図である。   FIG. 9 is a diagram illustrating an example of a part of the source code 23. FIG. 10 is a diagram illustrating an example of a tag used as a comment, and FIG. 11 is a diagram illustrating an example of an operator used as a comment.

図9には、メソッド"RegistUser"(図9のc1)用のテストプログラム22を作成するためのコメントの記載例が示されている。テスト担当者は、図10に示すタグおよび図11に示す演算子を用いて、メソッド"RegistUser"の各パラメータが取り得る値や設定したい値を、当該メソッド"RegistUser"の直前にコメントとして記載する。そして、このようなコメントが記載されたソースコード23が入力されると、ソースコード解析部12によって解析が施され、コメントに基づきテスト対象のメソッドが検出され、かつ、当該メソッドの各パラメータとして与えられるべきテストデータが作成される。また、各パラメータが取り得る値等がコメントとして記載されていた場合には(図10のタグ"@param.range"等を用いた記載が存在した場合)、ソースコード解析部12は、さらに、境界値試験を行うためのテストデータ(図11の「生成される入力値」欄参照)等を自動作成する。   FIG. 9 shows a description example of a comment for creating the test program 22 for the method “RegistUser” (c1 in FIG. 9). The tester uses the tag shown in FIG. 10 and the operator shown in FIG. 11 to describe the values that each parameter of the method “RegistUser” can take and the values to be set as comments immediately before the method “RegistUser”. . When the source code 23 in which such a comment is described is input, the source code analysis unit 12 performs analysis, detects a test target method based on the comment, and provides it as each parameter of the method. Test data to be performed is created. In addition, when a value that each parameter can take is described as a comment (when there is a description using the tag “@ param.range” in FIG. 10), the source code analysis unit 12 further Test data (see “Generated input value” column in FIG. 11) for performing the boundary value test is automatically created.

このソースコード解析部12の処理結果は、テストケース作成部13に転送され、ソースコード解析部12によって検出されたメソッドについて、ソースコード解析部12によって作成されたテストデータを全て網羅するテストケース24が作成される。そして、この第3実施形態の単体テストプログラム作成システム1におけるテストプログラム作成部11は、このテストケース24を順次読み出して、目的の値をパラメータとして与えた状況下で目的のメソッドをテストするためのテストプログラム22を作成して出力する。テストケース24は、中間ファイルとして作成されるので、テストケースを追加し、当該追加したテストケース用のテストプログラム22を併せて作成することも可能である。   The processing result of the source code analysis unit 12 is transferred to the test case creation unit 13, and a test case 24 that covers all the test data created by the source code analysis unit 12 for the method detected by the source code analysis unit 12. Is created. Then, the test program creation unit 11 in the unit test program creation system 1 of the third embodiment sequentially reads the test cases 24 and performs a test for testing the target method under the situation where the target value is given as a parameter. A program 22 is created and output. Since the test case 24 is created as an intermediate file, it is possible to add a test case and also create the test program 22 for the added test case.

なお、図9に示すように、メソッド"RegistUser"は、第3パラメータとしてオブジェクト"list"を受け取る(図9のc2)。そして、このオブジェクト"list"について、タグ"@param.mock"を用いることにより、当該オブジェクト"list"に与える値を設定することができる(図9のc3)。   As shown in FIG. 9, the method “RegistUser” receives the object “list” as the third parameter (c2 in FIG. 9). Then, by using the tag “@ param.mock” for this object “list”, a value to be given to the object “list” can be set (c3 in FIG. 9).

つまり、この第3実施形態の単体テストプログラム作成システム1においても、テスト担当者は、ソースコード23にコメントを記載するだけで、構造体を引数とするメソッドについて、その構造体を目的の値に設定した上でテストするためのテストプログラム22を簡単に作成することが可能となる。加えて、この第3実施形態の単体テストプログラム作成システム1では、境界値試験を行うためのテストプログラム22等を自動作成することが可能となる。   That is, also in the unit test program creation system 1 of the third embodiment, the tester simply sets a structure to a target value for a method having a structure as an argument, by simply writing a comment in the source code 23. In addition, it is possible to easily create a test program 22 for testing. In addition, the unit test program creation system 1 according to the third embodiment can automatically create a test program 22 and the like for performing a boundary value test.

(第4実施形態)
次に、この発明の第4実施形態について説明する。
(Fourth embodiment)
Next explained is the fourth embodiment of the invention.

前述した第3実施形態の単体テストプログラム作成システム1では、ソースコード23内に、目的のメソッドに対するコメントとして、そのメソッドに与えるテストデータの範囲や値等を記載した。   In the unit test program creation system 1 of the third embodiment described above, the range, value, etc. of the test data given to the method are described in the source code 23 as a comment for the target method.

これに対して、この第4実施形態の単体テストプログラム作成システム1は、検査対象の変数に対して所定のコメントを記載することで、当該検査対象の変数についての検証を行うためのテストプログラム22を作成するようにしたものである。図12は、第4実施形態におけるソースコード23の一部分の一例を示す図である。   On the other hand, the unit test program creation system 1 of the fourth embodiment includes a test program 22 for verifying the variable to be inspected by writing a predetermined comment for the variable to be inspected. It is something to be created. FIG. 12 is a diagram illustrating an example of a part of the source code 23 in the fourth embodiment.

図12には、変数"num"について定義する箇所の記載例が示されている。そして、ここでは、この変数"num"が検査対象であるものと想定する(図12のd1)。この場合、テスト担当者は、この変数"num"に対してコメント("Verified data")を記載する(図12のd2)。   FIG. 12 shows a description example of a part that defines the variable “num”. Here, it is assumed that this variable “num” is an inspection target (d1 in FIG. 12). In this case, the tester writes a comment (“Verified data”) for this variable “num” (d2 in FIG. 12).

一方、このようなコメントが記載されたソースコード23が入力されると、ソースコード解析部12によって解析が施され、まず、コメントに基づき検査対象の変数が検出される。検査対象の変数を検出すると、ソースコード解析部12は、続いて、この変数を引数や戻り値として含むオブジェクトが存在しないかを検索する。検出されたら、その変数と当該変数を引数や戻り値として含むオブジェクトとをテストプログラム作成部11に転送する。   On the other hand, when the source code 23 in which such a comment is described is input, the source code analysis unit 12 performs analysis, and first, a variable to be inspected is detected based on the comment. When a variable to be inspected is detected, the source code analysis unit 12 subsequently searches for an object including the variable as an argument or a return value. If detected, the variable and an object including the variable as an argument or return value are transferred to the test program creation unit 11.

そして、ソースコード解析部12の処理結果を受け取ったテストプログラム作成部11は、この変数についての検証を行うためのテストプログラム22を作成する。図13は、テストプログラム作成部11によってテストプログラム22が作成される原理を説明するための図である。   The test program creation unit 11 that has received the processing result of the source code analysis unit 12 creates a test program 22 for verifying the variable. FIG. 13 is a diagram for explaining the principle by which the test program 22 is created by the test program creation unit 11.

図13中のe1は、ソースコード解析部12によって検出された、変数"num"を引数として含むオブジェクトに関するソースコード23内における記載箇所である。一方、図13中のe2は、このような記載箇所が検出された場合に、テストプログラム作成部11によって作成されるテストプログラム22を示す。   E1 in FIG. 13 is a description location in the source code 23 relating to an object including the variable “num” as an argument, which is detected by the source code analysis unit 12. On the other hand, e2 in FIG. 13 indicates the test program 22 created by the test program creation unit 11 when such a description location is detected.

図13に示すように、テストプログラム作成部11は、変数"num"に対して"10"を与えたオブジェクトが存在した場合、その"10"を用いて変数"num"を検証するテストプログラム22を作成して出力する。   As shown in FIG. 13, when there is an object that gives “10” to the variable “num”, the test program creation unit 11 uses the “10” to verify the variable “num”. Create and output.

このように、この単体テストプログラム作成システム1によれば、テスト担当者は、ソースコード23のコメントを記載するだけで、検査対象の変数について検証するためのテストプログラム22を簡単に作成することが可能となる。   As described above, according to the unit test program creation system 1, the tester can easily create the test program 22 for verifying the variable to be inspected only by describing the comment of the source code 23. It becomes.

なお、前述の第3実施形態において説明したソースコード23に目的のメソッドに対してコメントを記載する手法と、この第4実施形態において説明したソースコード23に検証対象の変数に対してコメントを記載する手法とは、組み合わせて実施することが可能である。   Note that a method for writing a comment for a target method in the source code 23 described in the third embodiment and a comment for a variable to be verified are written in the source code 23 described in the fourth embodiment. It is possible to implement in combination with the technique to do.

以上のように、本発明のテストプログラム作成装置(単体テストプログラム作成システム1)によれば、例えば、階層構造を持つ構造体群を受け取って動作するプログラムをテストするためのテストプログラムを簡単に作成することが可能となる。   As described above, according to the test program creation apparatus (unit test program creation system 1) of the present invention, for example, a test program for testing a program that operates by receiving a structure group having a hierarchical structure is easily created. It becomes possible.

なお、本発明は、上記実施形態そのままに限定されるものではなく、実施段階ではその要旨を逸脱しない範囲で構成要素を変形して具体化できる。また、上記実施形態に開示されている複数の構成要素の適宜な組み合わせにより種々の発明を形成できる。例えば、実施形態に示される全構成要素から幾つかの構成要素を削除してもよい。更に、異なる実施形態に構成要素を適宜組み合わせてもよい。   Note that the present invention is not limited to the above-described embodiment as it is, and can be embodied by modifying the constituent elements without departing from the scope of the invention in the implementation stage. In addition, various inventions can be formed by appropriately combining a plurality of components disclosed in the embodiment. For example, some components may be deleted from all the components shown in the embodiment. Furthermore, you may combine a component suitably in different embodiment.

1…単体テストプログラム作成システム、11…テストプログラム作成部、12…ソースコード解析部、13…テストケース作成部、21…テストデータ定義データ、22…テストプログラム、23…ソースコード、24…テストケース。   DESCRIPTION OF SYMBOLS 1 ... Unit test program creation system, 11 ... Test program creation part, 12 ... Source code analysis part, 13 ... Test case creation part, 21 ... Test data definition data, 22 ... Test program, 23 ... Source code, 24 ... Test case.

Claims (5)

階層構造を持つ構造体群の最上位に位置する構造体を引数として受け取って動作するプログラムをテストするためのテストプログラムを作成するテストプログラム作成装置であって、
前記階層構造を持つ構造体群の各値を定義するテストデータ定義データを入力する入力手段と、
前記入力手段により入力されたテストデータ定義データで定義される各値を持つ前記階層構造を持つ構造体群を生成する手続きと、当該生成した構造体群の最上位に位置する構造体を引数としてテスト対象の前記プログラムを呼び出す手続きとを有する前記テストプログラムを作成するテストプログラム作成手段と、
を具備することを特徴とするテストプログラム作成装置。
A test program creation device for creating a test program for testing a program that operates by receiving a structure positioned at the top of a structure group having a hierarchical structure as an argument,
Input means for inputting test data definition data defining each value of the structure group having the hierarchical structure;
A procedure for generating a structure group having the hierarchical structure having each value defined by the test data definition data input by the input means, and a structure positioned at the top of the generated structure group as arguments Test program creating means for creating the test program having a procedure for calling the program to be tested;
A test program creation device comprising:
前記テストデータ定義データは、XML(extensible markup language)によって記載され、階層構造をタグで表すことによって、前記階層構造を持つ構造体群の各値をその構造に沿って定義するテキストデータであり、
前記テストプログラム作成手段は、前記テキストデータ定義データ中に埋め込まれたタグに基づき階層構造を解釈し、前記テストデータ定義データで定義される各値を持つ前記階層構造を持つ構造体群を生成する手続きを作成する、
ことを特徴とする請求項1記載のテストプログラム作成装置。
The test data definition data is text data that is described in XML (extensible markup language) and defines each value of the structure group having the hierarchical structure along the structure by expressing the hierarchical structure with a tag.
The test program creation means interprets a hierarchical structure based on a tag embedded in the text data definition data, and generates a structure group having the hierarchical structure having each value defined by the test data definition data. Create a procedure,
The test program creation device according to claim 1.
前記テストデータ定義データは、階層構造をインデントで表すことによって、前記階層構造を持つ構造体群の各値をその構造に沿って定義するテキストデータであり、
前記テストプログラム作成手段は、前記テキストデータ定義データ中で設定されたインデントに基づき階層構造を解釈し、当該テストデータ定義データで定義される各値を持つ前記階層構造を持つ構造体群を生成する手続きを作成する、
ことを特徴とする請求項1記載のテストプログラム作成装置。
The test data definition data is text data that defines each value of the structure group having the hierarchical structure along the structure by expressing the hierarchical structure by indentation,
The test program creation means interprets a hierarchical structure based on an indent set in the text data definition data, and generates a structure group having the hierarchical structure having each value defined by the test data definition data. Create a procedure,
The test program creation device according to claim 1.
構造体を引数として受け取って動作する関数を呼び出す手続きを有するプログラムについて前記関数単位のテストを実行するためのテストプログラムを作成するテストプログラム作成装置であって、
テスト対象の前記プログラムのソースコードであって、前記構造体の各値を定義するテストデータ定義データが前記関数に対するコメント文として記載されたソースコードを入力する入力手段と、
前記入力手段により入力されたソースコードを解析し、当該ソースコード内に記載されたコメント文に基づき、テスト対象の関数を検出すると共に、当該検出した関数に対して前記構造体として供給すべきテストデータを作成するテストケース作成手段と、
前記構造体として前記テストケース作成手段により作成されたテストデータを生成する手続きと、当該生成した前記構造体を引数として前記テスト対象の関数を呼び出す手続きとを有する前記テストプログラムを作成するテストプログラム作成手段と、
を具備することを特徴とするテストプログラム作成装置。
A test program creation device for creating a test program for executing a test in units of functions for a program having a procedure for calling a function that operates by receiving a structure as an argument,
Input means for inputting source code of the program to be tested, in which test data definition data defining each value of the structure is described as a comment statement for the function;
Analyzing the source code input by the input means, detecting a test target function based on a comment sentence described in the source code, and supplying the detected function as the structure A test case creation means for creating data;
Test program creation for creating the test program having a procedure for generating test data created by the test case creation means as the structure and a procedure for calling the function to be tested with the created structure as an argument Means,
A test program creation device comprising:
テスト対象のプログラムのソースコードであって、検査対象の変数を指定するためのコメント文が記載されたソースコードを入力する入力手段と、
前記入力手段により入力されたソースコードを解析し、当該ソースコード内に記載されたコメント文に基づき、検査対象の変数を検出すると共に、当該検出した変数を引数または戻り値とする関数を検出し、当該検出した関数が引数または戻り値とする前記検出した変数を検証するための手続きを有するテストプログラムを作成するテストプログラム作成手段と、
を具備することを特徴とするテストプログラム作成装置。
Input means for inputting source code of a program to be tested, which is a source code in which a comment sentence for specifying a variable to be inspected is written;
Analyzes the source code input by the input means, detects a variable to be inspected based on a comment sentence described in the source code, and detects a function having the detected variable as an argument or a return value. A test program creating means for creating a test program having a procedure for verifying the detected variable as an argument or a return value of the detected function;
A test program creation device comprising:
JP2009256483A 2009-11-09 2009-11-09 Test program creation device Pending JP2011100420A (en)

Priority Applications (2)

Application Number Priority Date Filing Date Title
JP2009256483A JP2011100420A (en) 2009-11-09 2009-11-09 Test program creation device
CN2010105365795A CN102053909A (en) 2009-11-09 2010-11-04 Test program generating device

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
JP2009256483A JP2011100420A (en) 2009-11-09 2009-11-09 Test program creation device

Publications (1)

Publication Number Publication Date
JP2011100420A true JP2011100420A (en) 2011-05-19

Family

ID=43958254

Family Applications (1)

Application Number Title Priority Date Filing Date
JP2009256483A Pending JP2011100420A (en) 2009-11-09 2009-11-09 Test program creation device

Country Status (2)

Country Link
JP (1) JP2011100420A (en)
CN (1) CN102053909A (en)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
WO2013108730A1 (en) * 2012-01-20 2013-07-25 日立オートモティブシステムズ株式会社 Software verification support device, software verification support method, software verification support program

Families Citing this family (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102629227B (en) * 2012-02-28 2015-07-22 中科开元信息技术(北京)有限公司 Method for assisting function verification of interface of embedded system
CN103605777B (en) * 2013-11-28 2017-04-12 北京国双科技有限公司 database index processing method and device

Citations (8)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JPH02247742A (en) * 1989-03-20 1990-10-03 Fujitsu Ltd Test program forming processing system
JPH0391039A (en) * 1989-09-04 1991-04-16 Fuji Electric Co Ltd Program for test for software and method for preparing test data
JPH05197589A (en) * 1991-11-22 1993-08-06 Nec Corp Automatic generation system of test program
JP2001084162A (en) * 1999-09-10 2001-03-30 Toshiba Corp Program testing method and storage medium
JP2004070561A (en) * 2002-08-05 2004-03-04 Funai Electric Co Ltd Debugging device
JP2005293578A (en) * 2004-03-31 2005-10-20 Microsoft Corp Test case inheritance controlled via attribute
JP2007058383A (en) * 2005-08-23 2007-03-08 Nomura Research Institute Ltd Operation verification system for program and operation verification program
JP2007316875A (en) * 2006-05-25 2007-12-06 Hitachi Ltd Apparatus and method for automatic regression test

Patent Citations (8)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JPH02247742A (en) * 1989-03-20 1990-10-03 Fujitsu Ltd Test program forming processing system
JPH0391039A (en) * 1989-09-04 1991-04-16 Fuji Electric Co Ltd Program for test for software and method for preparing test data
JPH05197589A (en) * 1991-11-22 1993-08-06 Nec Corp Automatic generation system of test program
JP2001084162A (en) * 1999-09-10 2001-03-30 Toshiba Corp Program testing method and storage medium
JP2004070561A (en) * 2002-08-05 2004-03-04 Funai Electric Co Ltd Debugging device
JP2005293578A (en) * 2004-03-31 2005-10-20 Microsoft Corp Test case inheritance controlled via attribute
JP2007058383A (en) * 2005-08-23 2007-03-08 Nomura Research Institute Ltd Operation verification system for program and operation verification program
JP2007316875A (en) * 2006-05-25 2007-12-06 Hitachi Ltd Apparatus and method for automatic regression test

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
WO2013108730A1 (en) * 2012-01-20 2013-07-25 日立オートモティブシステムズ株式会社 Software verification support device, software verification support method, software verification support program
JP2013149164A (en) * 2012-01-20 2013-08-01 Hitachi Automotive Systems Ltd Software verification support device, software verification support method, and software verification support program

Also Published As

Publication number Publication date
CN102053909A (en) 2011-05-11

Similar Documents

Publication Publication Date Title
JP5659238B2 (en) Source code conversion method and source code conversion program
WO2012032890A1 (en) Source code conversion method and source code conversion program
US20150135164A1 (en) Integrated Software Testing Management
JP5176478B2 (en) Data flow analysis device, data flow analysis method, and data flow analysis program
CN103294596A (en) Early warning method for contract-type software fault based on program invariants
Kammer et al. Gesture formalization for multitouch
Kresse et al. Development and maintenance efforts testing graphical user interfaces: a comparison
JP2011100420A (en) Test program creation device
JP5814603B2 (en) Test specification creation support apparatus, method and program
Wiederseiner et al. An open-source tool for automated generation of black-box xunit test code and its industrial evaluation
JP5163172B2 (en) Software test item editing support apparatus and software test item editing support method
Nazir et al. Identifying software features as birthmark
Salihu et al. Comparative analysis of GUI reverse engineering techniques
US20080276187A1 (en) Iconic Programming System with Disabling and Enabling of Dependent Objects
McFadden et al. Survey of aspect mining case study software and benchmarks
Ulmer et al. Virtual testing of high lift systems
JP5755861B2 (en) Test case generation apparatus, test case generation method, and test case generation program
JP2007257397A (en) Contention state detection process additional program, contention state detection process adding apparatus and contention state detection process adding method
Arcega et al. On the influence of models at run-time traces in dynamic feature location
JP5736588B2 (en) Source code conversion method and source code conversion program
Ibrahim et al. An eclipse plug-in tool for generating test cases from source codes
JP5755103B2 (en) Block diagram processing apparatus and block diagram processing method
US8930759B2 (en) Stream generation
Oliveira et al. Verification of plastic interactive systems
JP2004280231A (en) Verification method for software

Legal Events

Date Code Title Description
A977 Report on retrieval

Free format text: JAPANESE INTERMEDIATE CODE: A971007

Effective date: 20110824

A131 Notification of reasons for refusal

Free format text: JAPANESE INTERMEDIATE CODE: A131

Effective date: 20110906

A02 Decision of refusal

Free format text: JAPANESE INTERMEDIATE CODE: A02

Effective date: 20120207