Invention content
In view of this, the present invention provides a kind of generation method and system of test data, test case is being ensured to realize
Working efficiency is improved while with test data consistency.
A kind of generation method of test data, including:
The total page number n of test case list is calculated, wherein the test case list is Excel lists, including:
Test case numbered sequence, input time sequence, input signal title sequence, input number corresponding with input signal title sequence
According to sequence, output time series, output signal title sequence and output data sequence corresponding with output signal title sequence,
In, n is positive integer;
Since the first page of the test case list, gradually the test case in every page is converted, until n
Page all converts, and the transfer process of the test case in every page executes following steps:
The content for a plurality of test case for including is obtained in page to be converted, and calculates the test for including in the page to be converted
Use-case item number m, m are positive integer;
Since the page to be converted first test case, gradually each test case is converted, until m
Test case all converts, and the transfer process of each test case executes following steps:
The parameter needed to configure in test case to be converted is joined with corresponding in the parameter configuration table for obtaining and storing in advance
Several values are substituted, and the parameter configuration table is Excel lists, in the parameter configuration table record have configuration parameter name with
And configuration parameter respective value corresponding with the configuration parameter, the parameter needed to configure include:Input time sequence, with it is defeated
Enter the corresponding input data sequence of signal name sequence, output time series and output number corresponding with output signal title sequence
According to sequence;
The time series for the test case to be converted that parameter configuration is completed is converted into array type by character string type, number
Array type is converted to by character string type according to sequence, wherein time series includes input time sequence and output time series,
The data sequence includes input data sequence and output data sequence;
Whether the data sequence length of the length of time series and array type that judge array type is identical;
If it is, test data is defined, and will be at the beginning of all input signals in the initial value list that obtained and store in advance
Initial value is assigned to the test data, and the initial value list is tested software model corresponding with the test case list
The initial value list of all input signals, in the initial value list record have input signal title sequence and with the input
The corresponding input signal initial value of signal name sequence;
By the corresponding output letter of output signal title sequence in the test case to be converted completed with the parameter configuration
Number value is assigned to the test data, wherein the output signal value is sky;
The time series of array type is converted into corresponding time test data, the data sequence of array type is converted into
Corresponding data test data;
The time test data are assigned in the test data and input corresponding with the time test data
The corresponding position of the identical input signal title of signal name, while the data test data are assigned to the test data
In the identical input signal title of corresponding with data test data input signal title corresponding position.
Preferably, further include:
If it is not, then output information warning, and terminate Test data generation flow.
Preferably, described that the time series of array type is converted into corresponding time test data, the number of array type
Being converted into corresponding data test data according to sequence includes:
Judge the signal number for including in the use-case to be measured to be converted that the parameter configuration is completed is with data sequence number
It is no identical, wherein the signal number is the number summation of input signal and output signal, and data sequence number is input data
The number summation of sequence and output data sequence;
If it is, the time series of array type is converted into corresponding time test data, the data of array type
Sequence is converted into corresponding data test data.
Preferably, described that the time series of array type is converted into corresponding time test data, the number of array type
Being converted into corresponding data test data according to sequence includes:
It is described to judge whether the input signal for including in the use-case to be measured to be converted that the parameter configuration is completed is included in
In all input signal initial values;
If it is, the time series of array type is converted into corresponding time test data, the data of array type
Sequence is converted into corresponding data test data.
Preferably, when the time series is relative time, then the transfer process of relative time sequence is:
First data corresponding time of numerical value in the time series is set as 0, the c1 numerical value is corresponding absolutely
It is multiplied by default simulation step length after making difference with 1 to the time for the sum of all time points before the c1 time series, wherein c1 is big
In 1 positive integer.
A kind of generation system of test data, including:
Computing unit, the total page number n for test case list to be calculated, wherein the test case list is
Excel lists, including:Test case numbered sequence, input time sequence, input signal title sequence and input signal title
It the corresponding input data sequence of sequence, output time series, output signal title sequence and is answered with output signal title sequence pair
Output data sequence, wherein n is positive integer;
Since the first page of the test case list, gradually the test case in every page is converted, until n
Page all converts, and the transfer process of the test case in every page executes such as lower unit:
Acquiring unit, the content for obtaining in page to be converted a plurality of test case for including, and calculate described to be converted
Test case item the number m, m for including in page are positive integer;
Since the page to be converted first test case, gradually each test case is converted, until m
Test case all converts, and the transfer process of each test case executes such as lower unit:
Parameter configuration unit, for by the parameter needed to configure in the test case to be converted ginseng for obtaining and storing in advance
The value that parameter is corresponded in number allocation list is substituted, and the parameter configuration table is Excel lists, is recorded in the parameter configuration table
Have configuration parameter name and configuration parameter respective value corresponding with the configuration parameter, the parameter needed to configure include:
Input time sequence, input data sequence corresponding with input signal title sequence, output time series and with output signal name
Claim sequence corresponding output data sequence;
The time series of converting unit, the test case to be converted for completing parameter configuration is converted by character string type
For array type, data sequence is converted to array type by character string type, wherein time series include input time sequence and
Output time series, the data sequence include input data sequence and output data sequence;
Judging unit, the data sequence length of length of time series and array type for judging array type whether phase
Together;
Test data definition unit, in the case where the judging unit is judged as YES, defining test data, and will
All input signal initial values are assigned to the test data, the initial value row in the initial value list for obtaining and storing in advance
Table is the initial value list of all input signals of tested software model corresponding with the test case list, the initial value
Record has input signal title sequence and input signal initial value corresponding with the input signal title sequence in list;
First assignment unit, for by the output signal title in the test case to be converted completed with the parameter configuration
The corresponding output signal value of sequence is assigned to the test data, wherein the output signal value is sky;
Converting unit, for the time series of array type to be converted into corresponding time test data, array type
Data sequence is converted into corresponding data test data;
Second assignment unit, for by the time test data be assigned in the test data and with the time
The corresponding position of the identical input signal title of the corresponding input signal title of test data, while by the data test data
It is assigned to the identical input signal title of corresponding with data test data input signal title in the test data
Corresponding position.
Preferably, further include:
Alarm unit in the case where the judging unit is judged as NO, exporting information warning, and terminates to test number
According to product process.
Preferably, the converting unit includes:
First judgment sub-unit, the signal for judging to include in use-case to be measured to be converted that the parameter configuration is completed
Whether number is identical as data sequence number, wherein the signal number is the number summation of input signal and output signal, data
Sequence number is the number summation of input data sequence and output data sequence;
First conversion subunit, in the case where first judgment sub-unit is judged as YES, by array type
Time series is converted into corresponding time test data, and the data sequence of array type is converted into corresponding data test data.
Preferably, the converting unit includes:
Second judgment sub-unit, the input letter for judging to include in use-case to be measured to be converted that the parameter configuration is completed
Number whether it is included in all input signal initial values;
Second conversion subunit, in the case where second judgment sub-unit is judged as YES, by array type
Time series is converted into corresponding time test data, and the data sequence of array type is converted into corresponding data test data.
It can be seen from the above technical scheme that the present invention provides a kind of generation method of test data and system, make
Test case list is obtained into edlin and filing to test case with Excel, tests and uses from the first page of test case list
Example starts, and gradually obtains each test case content in every page, and substitute test case to be converted according to parameter configuration table
In the parameter that needs to configure, define test data, all input signal initial values in initial value list be assigned to the test number
According to the corresponding output signal value of output signal title sequence in the test case to be converted completed with parameter configuration is assigned to
Then time series and data sequence are converted into corresponding test data by the test data, and be assigned in test data with
The corresponding position for the identical input signal title of input signal title that time series and data sequence pair are answered.As can be seen that this
Invention files test case using Excel, and the automatic generating test case of Excel formats is tested number using Matlab
According to because being the test case of Excel formats of directly reading and change the outfit, the present invention is ensuring test case and test data
It is improved work efficiency while consistency.
Specific implementation mode
Following will be combined with the drawings in the embodiments of the present invention, and technical solution in the embodiment of the present invention carries out clear, complete
Site preparation describes, it is clear that described embodiments are only a part of the embodiments of the present invention, instead of all the embodiments.It is based on
Embodiment in the present invention, it is obtained by those of ordinary skill in the art without making creative efforts every other
Embodiment shall fall within the protection scope of the present invention.
The embodiment of the invention discloses a kind of generation method of test data and system, with realize ensure test case with
Working efficiency is improved while test data consistency.
Referring to Fig. 1, a kind of generation method flow chart of test data provided in an embodiment of the present invention, including step:
Step S11, the total page number n of test case list is calculated;
It should be noted that API (the Application by opening the corresponding Excel application layer programs of test case
Programming Interface, application programming interface) test case list is found, it is used to which test be calculated
The total page number n of example list.
Wherein, the test case list is Excel lists, including:Test case numbered sequence, input time sequence,
Input signal title sequence, input data sequence corresponding with input signal title sequence, output time series, output signal name
Claim sequence and output data sequence corresponding with output signal title sequence, wherein n is positive integer.
It should be noted that input signal title sequence refers specifically to test case compared with the input letter that initial value changes
Number title sequence, output signal title sequence refer specifically to test case and need the output signal title sequence observed.
The format write of test case list is referring specifically to table 1:
Table 1
From table 1 it follows that the format write of test case list is:First row indicates test case number
TestCaseNr, secondary series indicate that input time sequence InputTime, third row indicate input signal title sequence
InputVaribles, the 4th row indicate the corresponding input data sequence InputValue of third row input signal title sequence, the
Five row indicate output time series OutputTime, and the 6th row indicate output signal title sequence OutputVaribles, the 7th
Row indicate the corresponding output data sequence OutputValue of the 6th row output signal title sequence.
It should be noted that the test case if necessary to distinguish different function with different pages, can also increase page, respectively
The format of page is identical.
To keep test case list more perfect, some row can also be increased in test case list, to describe test case
Test main points, such as test case title etc..
Step S12, judge whether the i pages of number of pages in test case list is less than n+1, if so, thening follow the steps
Otherwise S13 terminates Test data generation flow;
Step S13, the content for a plurality of test case for including in i pages is obtained, and calculates the test for including in described i pages and uses
Example item number m, m are positive integer;
Step S14, by the parameter needed to configure in j test case with right in the parameter configuration table for obtaining and storing in advance
The value of parameter is answered to be substituted;
The parameter configuration table is Excel lists, in the parameter configuration table record have configuration parameter name and with institute
The corresponding configuration parameter respective value of configuration parameter is stated, the parameter needed to configure includes:Input time sequence and input signal
The corresponding input data sequence of title sequence, output time series and output data sequence corresponding with output signal title sequence
Row.
The format write of parameter configuration table is referring to table 2:
Table 2
From Table 2, it can be seen that the first row of parameter configuration table indicates that configuration parameter name, secondary series indicate configuration parameter
Respective value.
Wherein, in rendering parameter allocation list, parameter configuration table is independent one page.
It should be noted that when Parameters variation in test case to be converted, only need accordingly to join in undated parameter allocation list
Number.
To keep parameter configuration table more perfect, the row of characterising parameter can also be increased in parameter configuration table.
Step S15, the time series for the test case to be converted that parameter configuration is completed is converted into number by character string type
Set type, data sequence are converted to array type by character string type;
Wherein, time series includes input time sequence and output time series, and the data sequence includes input data
Sequence and output data sequence.
Whether the data sequence length of the length of time series and array type that step S16, judge array type is identical, such as
Fruit is to then follow the steps S17;
Step S17, test data is defined, and all input signals in the initial value list for obtaining and storing in advance are initial
Value is assigned to the test data;
Wherein, test data is an empty memory space, and the present invention by test case by converting corresponding test number
According to, and test data is added in the empty memory space named with test data, it completes Test cases technology testing number
According to process.
It should be noted that institute of the initial value list for tested software model corresponding with the test case list
There is the initial value list of input signal, being recorded in the initial value list has input signal title sequence and believe with the input
Number corresponding input signal initial value of title sequence.
The format write of initial value list is referring to table 3:
Table 3
Input signal |
Initial value |
sig1 |
0 |
sig2 |
0 |
sig3 |
0 |
sig4 |
0 |
sig5 |
0 |
From table 3 it is observed that the first row of initial value list indicates input signal title, the second class of the representation input signal
The corresponding input signal initial value of title.
After defined herein good initial value, every test case does not have to fill in indeclinable letter again in test case list
Number.
For ease of understanding, the row of description signal can also be increased.
Step S18, the output signal title sequence pair in the test case to be converted completed with the parameter configuration is answered
Output signal value be assigned to the test data;
Wherein, the output signal value is sky.
Step S19, the time series of array type is converted into corresponding time test data, the data sequence of array type
Row are converted into corresponding data test data;
Step S20, by the time test data be assigned in the test data and with the time test data pair
The corresponding position for the identical input signal title of input signal title answered, while the data test data being assigned to described
The corresponding position of the identical input signal title of corresponding with data test data input signal title in test data;
Step S21, judge whether j items are less than i pages of m+1, if so, thening follow the steps S22, otherwise, execute step
S23;
Step S22, j=j+1 is enabled, and returns to step S14;
Step S23, i=i+1 is enabled, and returns to step S12.
Wherein, the format write of test data is referring specifically to table 4:
Table 4
InputTime |
InputVaribles |
InputValue |
OutputTime |
OutputVaribles |
OutputValue |
*** |
*** |
*** |
*** |
|
*** |
*** |
*** |
*** |
*** |
|
*** |
It in summary it can be seen, the generation method of test data provided by the invention, test case compiled using Excel
It collects and files, obtain test case list, since the first page test case of test case list, gradually obtain in every page
Each test case content, and the parameter needed to configure in test case to be converted is substituted according to parameter configuration table, definition is surveyed
Data are tried, all input signal initial values in initial value list are assigned to the test data, will be waited for what parameter configuration was completed
The corresponding output signal value of output signal title sequence in transforming test cases is assigned to the test data, then by time sequence
Row and data sequence are converted into corresponding test data, and are assigned to and are answered with time series and data sequence pair in test data
The corresponding position of the identical input signal title of input signal title.As can be seen that the present invention using Excel to test case into
Row filing, using Matlab by the automatic generating test case test data of Excel formats, because being to directly read and change the outfit
The test case of Excel formats, so the present invention improves work while ensuring test case with test data consistency
Efficiency.
Secondly, the parameter configuration table that the present invention uses, when project variation leads to Parameters variation, test case still can be with
It reuses.
Finally, due to which the present invention is directed to the content in the reading Excel file of English by API, therefore, can avoid because of one
Secondary property reads too many content to be caused to overflow to Matlab memories.
It should be noted that input time sequence (InputTime) or output time series in test case list
(OutputTime) i-th of numerical value in indicates and input data sequence (InputValue) or output data sequence
(OutputValue) corresponding i-th of numerical value needs lasting emulation cycle number in.It can certainly usage time axis form table
Show which second data changes.
Illustrate the process (note of every Test cases technology test data:The format write output and input is identical, therefore
The mode of conversion is also identical):
Assuming that signal number (specific certain test case input signal number or output signal number) is v, time series
Array length is L (notes:Time series array is identical as data sequence array length);
From 1 to L, the process that the time series to each signal and numerical value are converted one by one includes:
Judge whether c1 is less than L+1;
If c1 is not less than L+1, by transformed data (including time test data and data test data) assignment
To the identical signal of signal domain name corresponding with transformed data in test data;
If c1 is less than L+1, judge whether c1 is equal to 1;
If c1 is equal to 1, judge whether c2 is less than v+1;
If c2 is less than v+1, domain name signal identical with the c2 signal in signal is found in test data, the
The c1 value of one row time shaft is 0, and the c1 data of the second column data axis are the c1 numerical value in data sequence;
If c1 is not equal to 1, judge whether c2 is less than v+1;
If c2 is less than v+1, the c1 value of first row time shaft is institute before the c1 value in time series array
There is the sum of value to subtract 1 again and then be multiplied by default simulation step length, the c1 data of the second column data axis are c1 in data sequence
Numerical value.
Wherein, the time series in the present invention is defined as relative time rather than absolute time, is defined as the excellent of relative time
Gesture is, if some point changes in time series, it is only necessary to a point is changed, and if it is absolute time, if
One of them time point changes, then all the points thereafter are required for respective change, and are not easy to the modification of test case.
The transfer process of relative time sequence is:
First data corresponding time of numerical value in the time series is set as 0, the c1 numerical value is corresponding absolutely
It is multiplied by default simulation step length after making difference with 1 to the time for the sum of all time points before the c1 time series, wherein when input
Between each data in sequence InputTime and output time series OutputTime be positive integer.
In order to further optimize the above embodiments, further including step:
If the length of time series of array type and the data sequence length of array type differ, warning letter is exported
Breath, and terminate Test data generation flow.
In order to further optimize the above embodiments, step S19 includes:
Step S191, judge the signal number for including in the use-case to be measured to be converted that the parameter configuration is completed and data sequence
Whether row number is identical, if so, thening follow the steps S192;
Wherein, the signal number is the number summation of input signal and output signal, and data sequence number is input number
According to the number summation of sequence and output data sequence.
Step S192, the time series of array type is converted into corresponding time test data, the data of array type
Sequence is converted into corresponding data test data.
It should be noted that when the signal number and data that include in the use-case to be measured to be converted that the parameter configuration is completed
When sequence number differs, then information warning is exported, and terminates Test data generation flow.
In order to further optimize the above embodiments, step S19 includes:
Step S193, judge whether the input signal for including in the use-case to be measured to be converted that the parameter configuration is completed all wraps
It is contained in all input signal initial values, if so, thening follow the steps S194;
Step S194, the time series of array type is converted into corresponding time test data, the data of array type
Sequence is converted into corresponding data test data.
It should be noted that the input signal for including in the use-case to be measured to be converted that the parameter configuration is completed all is not wrapped
When being contained in all input signal initial values, information warning is exported, and terminate Test data generation flow.
Corresponding with above method embodiment, the present invention also provides a kind of generation systems of 9 test data.
Referring to Fig. 2, a kind of structural schematic diagram of the generation system of test data provided in an embodiment of the present invention, including:
Computing unit 21, the total page number n for test case list to be calculated, wherein the test case list is
Excel lists, including:Test case numbered sequence, input time sequence, input signal title sequence and input signal title
It the corresponding input data sequence of sequence, output time series, output signal title sequence and is answered with output signal title sequence pair
Output data sequence, wherein n is positive integer;
Since the first page of the test case list, gradually the test case in every page is converted, until n
Page all converts, and the transfer process of the test case in every page executes such as lower unit:
Acquiring unit 22, the content for obtaining in page to be converted a plurality of test case for including, and wait turning described in calculating
Test case item the number m, m for including in skipping are positive integer;
Since the page to be converted first test case, gradually each test case is converted, until m
Test case all converts, and the transfer process of each test case executes such as lower unit:
Parameter configuration unit 23, for by the parameter needed to configure in test case to be converted in advance obtaining and store
The value that parameter is corresponded in parameter configuration table is substituted, and the parameter configuration table is Excel lists, is remembered in the parameter configuration table
Record has configuration parameter name and configuration parameter respective value corresponding with the configuration parameter, the parameter packet needed to configure
It includes:Input time sequence, input data sequence corresponding with input signal title sequence, output time series and and output signal
The corresponding output data sequence of title sequence;
The time series of converting unit 24, the test case to be converted for completing parameter configuration is turned by character string type
It is changed to array type, data sequence is converted to array type by character string type, wherein time series includes input time sequence
And output time series, the data sequence include input data sequence and output data sequence;
Judging unit 25, whether the data sequence length of length of time series and array type for judging array type
It is identical, if it is, executing test data definition unit 26;
Test data definition unit 26, in the case where the judging unit 26 is judged as YES, defining test data,
And all input signal initial values in the initial value list for obtaining and storing in advance are assigned to the test data, it is described initial
Value list is the initial value list of all input signals of tested software model corresponding with the test case list, described first
Record has input signal title sequence and input signal corresponding with the input signal title sequence initial in initial value list
Value;
First assignment unit 27, for by the output signal name in the test case to be converted completed with the parameter configuration
The corresponding output signal value of sequence is claimed to be assigned to the test data, wherein the output signal value is sky;
Converting unit 28, for the time series of array type to be converted into corresponding time test data, array type
Data sequence be converted into corresponding data test data;
Second assignment unit 29, for by the time test data be assigned in the test data and with it is described when
Between the identical input signal title of the corresponding input signal title of test data corresponding position, while by the data test number
According to being assigned in the test data the identical input signal title of corresponding with data test data input signal title
Corresponding position.
It in summary it can be seen, the generation system of test data provided by the invention compiles test case using Excel
It collects and files, obtain test case list, since the first page test case of test case list, gradually obtain in every page
Each test case content, and the parameter needed to configure in test case to be converted is substituted according to parameter configuration table, definition is surveyed
Data are tried, all input signal initial values in initial value list are assigned to the test data, will be waited for what parameter configuration was completed
The corresponding output signal value of output signal title sequence in transforming test cases is assigned to the test data, then by time sequence
Row and data sequence are converted into corresponding test data, and are assigned to and are answered with time series and data sequence pair in test data
The corresponding position of the identical input signal title of input signal title.As can be seen that the present invention using Excel to test case into
Row filing, using Matlab by the automatic generating test case test data of Excel formats, because being to directly read and change the outfit
The test case of Excel formats, so the present invention improves work while ensuring test case with test data consistency
Efficiency.
Secondly, the parameter configuration table that the present invention uses, when project variation leads to Parameters variation, test case still can be with
It reuses.
Finally, due to which the present invention is directed to the content in the reading Excel file of English by API, therefore, can avoid because of one
Secondary property reads too many content to be caused to overflow to Matlab memories.
In order to further optimize the above embodiments, further including:
Alarm unit, in the case where judging unit 25 is judged as NO, exporting information warning, and terminate test data
Product process.
Wherein, converting unit 28 includes:
First judgment sub-unit 281, the letter for judging to include in use-case to be measured to be converted that the parameter configuration is completed
Whether number number and data sequence number are identical;
Wherein, the signal number is the number summation of input signal and output signal, and data sequence number is input number
According to the number summation of sequence and output data sequence;
First conversion subunit 282, in the case where the first judgment sub-unit 281 is judged as YES, by array type
Time series be converted into corresponding time test data, the data sequence of array type is converted into corresponding data test number
According to.
It should be noted that when the signal number and data that include in the use-case to be measured to be converted that the parameter configuration is completed
When sequence number differs, then information warning is exported, and terminates Test data generation flow.
In order to further optimize the above embodiments, converting unit 28 further includes:
Second judgment sub-unit 283, it is defeated for judge to include in use-case to be measured to be converted that the parameter configuration is completed
Enter whether signal is included in all input signal initial values;
Second conversion subunit 284, in the case where the second judgment sub-unit 283 is judged as YES, by array type
Time series be converted into corresponding time test data, the data sequence of array type is converted into corresponding data test number
According to.
It should be noted that the input signal for including in the use-case to be measured to be converted that the parameter configuration is completed all is not wrapped
When being contained in all input signal initial values, information warning is exported, and terminate Test data generation flow.
It should be noted that in system embodiment, the concrete operating principle of each component part refers to embodiment of the method pair
Part, the present invention is answered not to limit herein.
Finally, it is to be noted that, herein, relational terms such as first and second and the like be used merely to by
One entity or operation are distinguished with another entity or operation, without necessarily requiring or implying these entities or operation
Between there are any actual relationship or orders.Moreover, the terms "include", "comprise" or its any other variant meaning
Covering non-exclusive inclusion, so that the process, method, article or equipment including a series of elements includes not only that
A little elements, but also include other elements that are not explicitly listed, or further include for this process, method, article or
The intrinsic element of equipment.In the absence of more restrictions, the element limited by sentence "including a ...", is not arranged
Except there is also other identical elements in the process, method, article or apparatus that includes the element.
Each embodiment is described by the way of progressive in this specification, the highlights of each of the examples are with other
The difference of embodiment, just to refer each other for identical similar portion between each embodiment.
The foregoing description of the disclosed embodiments enables those skilled in the art to implement or use the present invention.
Various modifications to these embodiments will be apparent to those skilled in the art, as defined herein
General Principle can be realized in other embodiments without departing from the spirit or scope of the present invention.Therefore, of the invention
It is not intended to be limited to the embodiments shown herein, and is to fit to and the principles and novel features disclosed herein phase one
The widest range caused.