CN106021094A - Program static analysis based Java unit test teaching feedback method - Google Patents
Program static analysis based Java unit test teaching feedback method Download PDFInfo
- Publication number
- CN106021094A CN106021094A CN201610294181.2A CN201610294181A CN106021094A CN 106021094 A CN106021094 A CN 106021094A CN 201610294181 A CN201610294181 A CN 201610294181A CN 106021094 A CN106021094 A CN 106021094A
- Authority
- CN
- China
- Prior art keywords
- source program
- test
- data
- coverage
- node
- 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
Links
Classifications
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F11/00—Error detection; Error correction; Monitoring
- G06F11/36—Preventing errors by testing or debugging software
- G06F11/3668—Software testing
- G06F11/3672—Test management
- G06F11/3684—Test management for test design, e.g. generating new test cases
-
- G—PHYSICS
- G09—EDUCATION; CRYPTOGRAPHY; DISPLAY; ADVERTISING; SEALS
- G09B—EDUCATIONAL OR DEMONSTRATION APPLIANCES; APPLIANCES FOR TEACHING, OR COMMUNICATING WITH, THE BLIND, DEAF OR MUTE; MODELS; PLANETARIA; GLOBES; MAPS; DIAGRAMS
- G09B7/00—Electrically-operated teaching apparatus or devices working with questions and answers
- G09B7/02—Electrically-operated teaching apparatus or devices working with questions and answers of the type wherein the student is expected to construct an answer to the question which is presented or wherein the machine gives an answer to the question presented by a student
- G09B7/04—Electrically-operated teaching apparatus or devices working with questions and answers of the type wherein the student is expected to construct an answer to the question which is presented or wherein the machine gives an answer to the question presented by a student characterised by modifying the teaching programme in response to a wrong answer, e.g. repeating the question, supplying a further explanation
Landscapes
- Engineering & Computer Science (AREA)
- Theoretical Computer Science (AREA)
- Physics & Mathematics (AREA)
- General Physics & Mathematics (AREA)
- Business, Economics & Management (AREA)
- Educational Administration (AREA)
- Educational Technology (AREA)
- Computer Hardware Design (AREA)
- Quality & Reliability (AREA)
- General Engineering & Computer Science (AREA)
- Debugging And Monitoring (AREA)
Abstract
The invention provides a program static analysis based Java unit test teaching feedback method. The method includes the following steps: 1) analyzing a source program code static structure; 2) generating source program test demands; 3) writing Java unit test cases; 4) acquiring test case coverage data; 5) summarizing and counting the test cases and the coverage data; 6) visually displaying the source program code static structure and the coverage data; and 7) displaying an execution flow of a single test case on the source program code static structure. The method can solve the problem that Java unit test teaching tasks are difficult to train and assess in the current software test course, provide programming training, automatic assessment and a visual display platform for Java unit test, can greatly improve the training efficiency and the assessment efficiency of the teaching tasks, can help teachers improve the teaching content according to training feedback, and can help students improve the writing ability of the test cases according to the training feedback.
Description
Technical field
The invention belongs to software testing technology field, and in particular to a kind of Java unit testing based on Program Static Analysis
Teaching feedback method.
Background technology
Software test is one is intended to the inquiry activity that helper applications practitioner assesses the quality condition of tested software.Complete
In software development flow, software test activity is carried throughout, occupies the most of the time of development project, the most outstanding
Tester's demand in the field of business is the biggest.And software test is as a core professional class in software engineering education system, cultivates and learn
Raw to software quality and the attention of code quality, carry connection educational circles and the function served as bridge of industrial quarters, cultivate for IT industry circle
Outstanding developer and tester.
White-box testing is a vital task in software test teaching, and we are generally as a example by Java unit testing, to improve
Student is target to the understandability of source program and the ability of writing of test case.Current present situation is that student can by Eclipse
To be easy to write Java unit testing, but there is following incomplete place: 1, student cannot assess the survey oneself write
The intensity of example on probation;2, teacher cannot assess student and the most conscientiously writes;3, free practice can only be arranged, it is impossible to organizational unit
The programming examination of test.Exactly because the environment residing for Faculty and Students is relatively isolated in terms of white-box testing, teacher is difficult to collect
Student's degree of understanding to test assignment point, it is difficult to improve the content of courses according to actual feedback.The most traditional this test teaching
Method cannot meet the training objective of outstanding test development personnel.
Summary of the invention
Present invention aim at providing a kind of Java unit testing teaching feedback method based on Program Static Analysis, solve at present
Java unit testing is difficult to assess the problem being difficult to tissue examination, helps Faculty and Students to set up Two-way Feedback, and teacher is according to instead
Feedback improves the content of courses, and student writes ability according to what feedback improved constantly test case.
For reaching above-mentioned purpose, the present invention provides a kind of Java unit testing teaching feedback method based on Program Static Analysis.Side
Method comprises the following steps:
1) source program code static structure is analyzed.Bytecode program after using Soot framework to compile Java source program is controlled
Flow point processed is analysed, and obtains the control flow data of source program, and they change into general data form stores in file.The most right
Each function of each class of source program can obtain a JSON formatted file, wherein records the every of source program code static structure
The intermediate command set of individual node, the source program start-stop line number that each node is corresponding, and the predecessor node of each node and follow-up joint
Point.
2) generation of source program testing requirement.Utilize step 1) the source program static structure that obtains, generate code coverage and branch
The testing requirement covered, subpath i.e. to be comprised on test execution path.Wherein the testing requirement create-rule of code coverage is
Using node each in source program static structure as a testing requirement, and the testing requirement create-rule that branch covers is by source
In Program Static Structure, each branch is as a testing requirement.
3) Java unit testing use-case is write.Student writes test case, program the most to be measured (source program) in Eclipse
The exercise question that the exercise built-in from system or teacher specify.
4) test case coverage rate data acquisition.Utilize step 1) the source program static structure data that generate, use code pitching pile
Technology, carries out pitching pile to the corresponding source program statement of each node.Then JUnit external member is utilized by step 3) middle school student's volume
The unit testing use-case write operates on the source program after pitching pile, and collects the output information of pitching pile.From the output information of pitching pile
Extract the node path on the source program that test case goes to, i.e. test execution path, last and step 2) the middle survey generated
Examination demand compares, and calculates test coverage, and wherein code coverage computing formula is as follows:
In formula, N is all nodes of source program static structure Graph, and n is the number of all node N, and p is test use cases
Any one test execution path in conjunction,Represent that there is a test execution path p covers node Ni。
Branch covering rate computing formula is as follows:
In formula, B is all branches of source program static structure Graph, and b is the number of all branch B, and p is test use cases
Any one test execution path in conjunction,Represent that there is a test execution path p covers branch Bi。
5) test case and coverage data collect statistics.By step 3) the unit testing use-case write of middle school student and step 4)
In the coverage data that obtains be submitted to server together, at server end to the test case of identical sources program and coverage data
Carrying out collecting statistics, after wherein collecting, the coverage rate computing formula of each testing requirement is:
In formula, req is the arbitrary testing requirement of source program, and s is pupil load, psFor arbitrary test execution path of arbitrary student,Represent and there is a test execution path psCover testing requirement req.
6) visualization of source program static structure and coverage data represents.In step 1) in use Soot framework to Java source
When program is controlled flow point analysis, it is intended that the control flow data of generation is DOT formatted file (DOT is a kind of picture description language),
Then (SVG is can be in a browser to use the dot order in Graphviz instrument that data file exports to SVG formatted file
The saleable vector graphics format used).For each function of each class of source program, by source program word corresponding for each node
Sentence, and the coverage data of each testing requirement after collecting, be mapped with the node on SVG controlling stream graph, last
Rise and represent in a browser.
7) single test case execution flow process in source program static structure represents.In step 6) in select on the figure that represents
Certain testing requirement, from step 5) find out all coverings and do not cover the test case of this testing requirement in the data that collect.
Then one test case of reselection, according to step 4) in the test case execution route data that collect, by execution route exhibition
Now on SVG figure.
Further, wherein above-mentioned steps 1) specifically comprise the following steps that
Step 1)-1: initial state;
Step 1)-2: Java source program (program to be measured) is compiled into .class file (Java bytecode program);
Step 1)-3: use Soot framework that .class file is controlled flow point analysis, obtain BlockGraph (Soot frame
A kind of data structure defined in frame) i.e. the control flow data of source program;
Step 1)-4: BlockGraph is grouped according to class and the function of source program, data are changed into general JSON
Form;
Step 1)-5: JSON data are individually stored into a data file for each function of each class of source program;
Step 1)-6: source program code static structure is analyzed complete;
Further, wherein above-mentioned steps 2) specifically comprise the following steps that
Step 2)-1: initial state;
Step 2)-2: each function of class each to source program, reads the JSON data of corresponding source program static structure
File;
Step 2)-3: each node in traversal static structure, obtain the testing requirement of code coverage, store in file;
Step 2)-4: the node pair that each node in traversal static structure is formed with its descendant node, obtain what branch covered
Testing requirement, stores in file;
Step 2)-5: the generation of source program testing requirement is complete;
Further, wherein above-mentioned steps 3) specifically comprise the following steps that
Step 3)-1: initial state;
Step 3)-2: teacher creates examination or exercise, it is intended that program to be measured;
Step 3)-3: student logs in the account number of oneself in Eclipse, downloads examination or the program to be measured of exercise;
Step 3)-4: student writes Java unit testing use-case;
Step 3)-5:Java unit testing use-case writes complete;
Further, wherein above-mentioned steps 4) specifically comprise the following steps that
Step 4)-1: initial state;
Step 4)-2: each node of ergodic source Program Static Structure, pitching pile after the source program statement that each node is corresponding
Implant audiomonitor statement;
Step 4)-3: the unit testing use-case using JUnit external member student to be write performs on the source program after pitching pile;
Step 4)-4: resolve the output result of pitching pile audiomonitor statement, extract test case execution route on source program;
Step 4)-5: for each function of each class of source program, calculate code coverage and branch covering rate;
Step 4)-6: test case coverage rate data acquisition is complete;
Further, wherein above-mentioned steps 5) specifically comprise the following steps that
Step 5)-1: initial state;
Step 5)-2: student completes Java unit testing examination or exercise in Eclipse;
Step 5)-3: test case program and the coverage data of student are returned to server by system;
Step 5)-4: the test question arranging same teacher or identical exercise, calculate each testing requirement passes through people
Number, obtains the average coverage rate of testing requirement;
Step 5)-5: test case and collecting of coverage data add up complete;
Further, wherein above-mentioned steps 6) specifically comprise the following steps that
Step 6)-1: initial state;
Step 6)-2: use the command line parameter provided in Soot framework that the .class file of source program is controlled flow point analysis,
And to specify the data form of generation be .dot file;
Step 6)-3: .dot file is exported to .svg graphic file by the dot order using Graphviz instrument to provide;
Step 6)-4: each function of class each to source program, would indicate that the SVG graphic file of its code static structure shows
In a browser;
Step 6)-5: each testing requirement coverage data obtained test case after collecting and coverage data, and tie up
Determine in the respective nodes and path of SVG figure;
Step 6)-6: the visualization of source program static structure and coverage data represents complete;
Further, wherein above-mentioned steps 7) specifically comprise the following steps that
Step 7)-1: initial state;
Step 7)-2: on the SVG figure of source program static structure and testing requirement coverage data, select certain testing requirement;
Step 7)-3: the test case after collecting is found out the test case covering and not covering this testing requirement, is browsing
Device represents;
Step 7)-4: select some test case, from the test case coverage rate data gathered, find out this test case
Execution route data;
Step 7)-5: the node in traversal test execution path, the SVG figure of source program static structure marks out,
Represent the node animation in test execution path in a browser;
Step 7)-6: single test case execution flow process in source program static structure represents complete;
The present invention, based on program control flow analysis, utilizes Soot framework to simplify the acquisition process of Program Static Structure;Use code
Pitching pile technology and JUnit framework, obtained test case execution route accurately, covers according to code coverage and branch simultaneously
Rate, it is achieved that automatization's assessment of test case;And construct one and test examination paper from teacher's designating unit, write to student
Unit testing use-case, then the platform represented is visualized to browser front end, define teacher and arrive the closed loop of teacher again to student, greatly
Width improves organizational unit test examination and the efficiency of exercise;Contribute to teacher and according to examination and practise the feedback improvements content of courses,
Student constantly promotes the ability writing test case according to the feedback that test exemple automation assessment and visualization represent simultaneously, thus
Form the Two-way Feedback mechanism of Java unit testing teaching.
Accompanying drawing explanation
Fig. 1 is the flow chart of a kind of based on Program Static Analysis the Java unit testing teaching feedback method of the embodiment of the present invention.
Fig. 2 is the flow chart that in Fig. 1, source program code static structure is analyzed.
Fig. 3 is the flow chart of the generation of source program testing requirement in Fig. 1.
Fig. 4 is the flow chart that in Fig. 1, Java unit testing use-case is write.
Fig. 5 is the flow chart of test case coverage rate data acquisition in Fig. 1.
Fig. 6 is test case and the flow chart collecting statistics of coverage data in Fig. 1.
Fig. 7 is the flow chart that in Fig. 1, the visualization of source program static structure and coverage data represents.
Fig. 8 is the flow chart that in Fig. 1, single test case execution flow process in source program static structure represents.
Detailed description of the invention
In order to know more about the technology contents of the present invention, especially exemplified by specific embodiment and coordinate institute's accompanying drawings to be described as follows.
Fig. 1 is the flow chart of a kind of based on Program Static Analysis the Java unit testing teaching feedback method of the embodiment of the present invention.
A kind of Java unit testing teaching feedback method based on Program Static Analysis, it is characterised in that comprise the following steps:
S101 source program code static structure is analyzed.Bytecode program after using Soot framework to compile Java source program is carried out
Control flow analysis, obtains the control flow data of source program, and they change into general data form stores in file.Finally
Each function of class each to source program can obtain a JSON formatted file, wherein records source program code static structure
The intermediate command set of each node, the source program start-stop line number that each node is corresponding, and the predecessor node of each node and follow-up
Node.
The generation of S102 source program testing requirement.Utilizing source program static structure, the test generating code coverage and branch's covering needs
Ask, subpath i.e. to be comprised on test execution path.
S103 Java unit testing use-case is write.Student writes test case, program the most to be measured (source journey in Eclipse
Sequence) exercise question specified from the built-in exercise of system or teacher.
S104 test case coverage rate data acquisition.Utilize source program static structure data, use code pitching pile technology, to each
The corresponding source program statement of node carries out pitching pile.Then the unit testing use-case utilizing JUnit external member student to be write operates in
On source program after pitching pile, and collect the output information of pitching pile.The source that test case goes to is extracted from the output information of pitching pile
Node path in program, i.e. test execution path, finally compare with testing requirement, calculates test coverage.
S105 test case and coverage data collect statistics.The unit testing use-case that student is write and calculated covering
Rate data are submitted to server together, at server end, test case and the coverage data of identical sources program are collected statistics.
The visualization of S106 source program static structure and coverage data represents.Using Soot framework, Java source program is carried out
During control flow analysis, it is intended that the control flow data of generation is DOT formatted file (DOT is a kind of picture description language), then
(SVG is to use in a browser to use the dot order in Graphviz instrument that data file exports to SVG formatted file
Saleable vector graphics format).For each function of each class of source program, by source program statement corresponding for each node,
And the coverage data of each testing requirement after collecting, it is mapped with the node on SVG controlling stream graph, eventually exists
Browser represents.
S107 single test case execution flow process in source program static structure represents.SVG figure select certain test need
Ask, from the data collecting statistics, find out all coverings and do not cover the test case of this testing requirement.Then reselection one survey
Example on probation, according to the test case execution route data collected, is presented in execution route on SVG figure.
Fig. 2 is the flow chart that source program code static structure is analyzed.Byte after using Soot framework that Java source program is compiled
Coded program is controlled flow point analysis, obtains the control flow data of source program, and they change into general data form stores literary composition
In part.Finally each function of class each to source program can obtain a JSON formatted file, wherein records source program code
The intermediate command set of each node of static structure, the source program start-stop line number that each node is corresponding, and the forerunner of each node
Node and descendant node.
Below as a example by one section of source program, tell about the concrete steps that source program code static structure is analyzed.Source program Hello.java
As follows:
Table 1 source program sample table
Step 1: initial state;
Step 2: Hello.java is compiled into Hello.class file (Java bytecode program);
Step 3: use Soot framework that Hello.class file is controlled flow point analysis, obtain BlockGraph (Soot
A kind of data structure defined in framework) i.e. the control flow data of source program;
Step 4: be grouped according to class and function by BlockGraph, for the foo function of current Hello class, by data
Change into general JSON form, as follows:
Table 2 controls stream sample table
Wherein " 0 "~" 4 " represents the numbering (Hello.java program is divided into 5 pieces altogether) to source program code blocking node,
" instructions " represents the interlude instruction that this block codes is corresponding, and " sline "/" spos " represents that instruction is at source program respectively
Line number that place code is initial and columns, " eline "/" epos " represents respectively and instructs at the line number of source program place code termination and row
Number, and " preds "/" succs " represents the predecessor node of this piecemeal and piecemeal numbering (forerunner and the descendant node of descendant node respectively
All there may be multiple);
Step 5: JSON data are individually stored into a data file for each function of each class of source program, existing for
The data of table 2 are saved as " Hello-int foo (int) .json " file by the foo function of Hello class;
Step 6: source program code static structure is analyzed complete.
Fig. 3 is the flow chart that source program testing requirement generates.Utilize source program static structure, generate code coverage and branch covers
Testing requirement, subpath i.e. to be comprised on test execution path.The most still as a example by Hello.java program, tell about source journey
The concrete steps that sequence testing requirement generates:
Step 1: initial state;
Step 2: for the foo function of Hello class, reads the JSON data of corresponding source program static structure, i.e.
" Hello-int foo (int) .json " file;
Step 3: each node in traversal static structure, obtains the testing requirement of code coverage, i.e. blocking node
[" 0 ", " 1 ", " 2 ", " 3 ", " 4 "], store in file;
Step 4: the node pair that each node in traversal static structure is formed with its descendant node, obtains the test that branch covers
Demand, i.e. node, to [" 0-1 ", " 0-2 ", " 1-3 ", " 2-4 ", " 3-4 "], store in file;
Step 5: the generation of source program testing requirement is complete.
Fig. 4 is the flow chart that Java unit testing use-case is write.Student writes test case in Eclipse, wherein treats ranging
The exercise question that sequence (source program) is specified from the built-in exercise of system or teacher.The most still as a example by Hello.java program, say
State the concrete steps that Java unit testing use-case is write:
Step 1: initial state;
Step 2: teacher creates examination or exercise, it is intended that program to be measured is Hello.java;
Step 3: student logs in the account number of oneself in Eclipse, downloads examination or the program to be measured of exercise;
Step 4: student writes Java unit testing use-case, such as table 3;
Step 5:Java unit testing use-case is write complete.
Table 3 unit testing sample table
Fig. 5 is the flow chart of test case coverage rate data acquisition.Utilize source program static structure data, use code pitching pile skill
Art, carries out pitching pile to the corresponding source program statement of each node.Then the unit testing that student is write by JUnit external member is utilized
Use-case operates on the source program after pitching pile, and collects the output information of pitching pile.Test case is extracted from the output information of pitching pile
The node path on source program gone to, i.e. test execution path, finally compare with testing requirement, calculates Test coverage
Rate.Below in table 2 as a example by the HelloTest test program in Hello.java source program code static structure data and table 3,
Tell about the concrete steps of test case coverage rate data acquisition:
Step 1: initial state;
Step 2: ergodic source Program Static Structure " 0 "~each node of " 4 ", after the interlude instruction that each node is corresponding
Pitching pile implants audiomonitor statement, the i.e. instruction of output present node numbering;
Step 3: use JUnit external member to be performed on the source program after pitching pile by HelloTest unit testing use-case;
Step 4: resolve the output result of pitching pile audiomonitor statement, extracts test case execution route on source program, i.e.
“0-1-3-4”;
Step 5: for the foo function of Hello class, code coverage testing requirement is [" 0 ", " 1 ", " 2 ", " 3 ", " 4 "], so path
The code coverage of " 0-1-3-4 " is 4/5, and branch's coverage test demand is [" 0-1 ", " 0-2 ", " 1-3 ", " 2-4 ", " 3-4 "], so road
The branch covering rate in footpath " 0-1-3-4 " is 3/5;
Step 6: test case coverage rate data acquisition is complete.
Fig. 6 is the flow chart that test case and coverage data collect statistics.The unit testing use-case that student is write and calculating
To coverage data be submitted to server together, at server end, test case and the coverage data of identical sources program are carried out
Collect statistics.Specifically comprise the following steps that
Step 1: initial state;
Step 2: student completes Java unit testing examination or exercise in Eclipse;
Step 3: test case program and the coverage data of student are returned to server by system;
Step 4: the test question that same teacher is arranged or identical exercise, calculate each testing requirement by number,
Obtain the average coverage rate of testing requirement;
Step 5: test case and collecting of coverage data add up complete.
Fig. 7 is that source program static structure and coverage data visualize the flow chart represented.Using Soot framework to Java source
When program is controlled flow point analysis, it is intended that the control flow data of generation is DOT formatted file (DOT is a kind of picture description language),
Then (SVG is can be in a browser to use the dot order in Graphviz instrument that data file exports to SVG formatted file
The saleable vector graphics format used).For each function of each class of source program, by source program word corresponding for each node
Sentence, and the coverage data of each testing requirement after collecting, be mapped with the node on SVG controlling stream graph, last
Rise and represent in a browser.The most still as a example by Hello.java program, tell about source program static structure and coverage data is visual
The concrete steps that change represents:
Step 1: initial state;
Step 2: the command line parameter using Soot framework to provide is controlled flow point analysis to the Hello.class file of source program,
For the foo function of Hello class, CFGToDotGraph is utilized (controlling stream graph to be changed into by Soot framework connecing of DOT file
Mouthful) specify data genaration to " Hello-int foo (int) .dot " file, file content such as table 4;
Table 4 DOT sample table
Step 3: " Hello-int foo (int) .dot " file is exported to by the dot order using Graphviz instrument to provide
" Hello-int foo (int) .svg " graphic file, file content such as table 5;
Table 5 SVG sample table
Step 4: for the foo function of Hello class, would indicate that " Hello-int foo (int) .svg " of its code static structure
Graphic file shows in a browser;
Step 5: each testing requirement coverage data obtained test case after collecting and coverage data, and be tied to
In the respective nodes of SVG figure and path;
Step 6: the visualization of source program static structure and coverage data represents complete.
Fig. 8 is the flow chart that single test case execution flow process in source program static structure represents.SVG figure selects
Certain testing requirement, finds out all coverings from the data collecting statistics and does not covers the test case of this testing requirement.The most again
Select a test case, according to the test case execution route data collected, execution route is presented on SVG figure.
Specifically comprise the following steps that
Step 1: initial state;
Step 2: select certain testing requirement on the SVG figure of source program static structure and testing requirement coverage data;
Step 3: find out the test case covering and not covering this testing requirement the test case after collecting, in a browser
Represent;
Step 4: select some test case, finds out the execution of this test case from the test case coverage rate data gathered
Path data;
Step 5: the node in traversal test execution path, marks out, clear on the SVG figure of source program static structure
Look at and device represents the node animation in test execution path;
Step 6: single test case execution flow process in source program static structure represents complete.
In sum, during the present invention solves current software test course, Java unit testing teaching task is difficult to exercise and is difficult to assess
Problem, provide not only the programming exercise for Java unit testing and automatization's assessment and the platform that represents of visualization, and
And greatly improve teaching task exercise and assessment efficiency, contribute to teacher according to exercise the feedback improvements content of courses, contribute to
Student writes ability according to exercise feedback constantly lifting test case.
Claims (8)
1. a Java unit testing teaching feedback method based on Program Static Analysis, it is characterised in that utilize programme-control
Flow point analysis obtains the static structure of source program code, and obtains code coverage and the testing requirement of branch's covering according to static structure,
To realize automatization's assessment of test case;Teacher's authorized examination and exercise exercise question, student writes test case;System acquisition is surveyed
Example on probation and coverage data, and carry out collecting statistics, represent source program static structure and overall coverage rate the most in a browser
Data, and the execution flow process that single test case is in source program static structure.Comprise the following steps:
1) source program code static structure is analyzed, and the bytecode program after using Soot framework to compile Java source program is carried out
Control flow analysis, obtains the control flow data of source program, and they change into general data form stores in file.Finally
Each function of class each to source program can obtain a JSON formatted file, wherein records source program code static structure
The intermediate command set of each node, the source program start-stop line number that each node is corresponding, and the predecessor node of each node and after
Continue node;
2) generation of source program testing requirement;
Definition 1: test execution path is the source program statement sequence that test case goes to;
Definition 2: code coverage is a kind of test index, refers to testing results use-case so that each executable statement in source program
At least perform once;
Definition 3: it is a kind of test index that branch covers, and refers to testing results use-case so that in source program, each judgement takes true point
Propping up and take false ramification and at least experience once, the true-false value i.e. judged the most once was satisfied;
Definition 4: testing requirement refers to each path characteristics covering point in test index.Given test index C, test
The path characteristics set of index is designated as TR, i.e. testing requirement.A given test case set T, the test execution road of its correspondence
Footpath set is designated as P.When for each testing requirement tr in TR, a test execution path being found in P to meet tr,
We just claim test case T to meet testing requirement TR;
Utilize step 1) the source program static structure that obtains, generate code coverage and testing requirement that branch covers;
3) Java unit testing use-case is write, and student writes test case, program the most to be measured (source program) in Eclipse
The exercise question that the exercise built-in from system or teacher specify;
4) test case coverage rate data acquisition;
Definition 1: code coverage refers to that test case meets the percentage rate of code coverage testing requirement, and computing formula is as follows:
In formula, N is all nodes of source program static structure Graph, and n is the number of all node N, and p is test use cases
Any one test execution path in conjunction,Represent that there is a test execution path p covers node Ni。
Definition 2: branch covering rate refers to that test case meets the percentage rate of branch's coverage test demand, and computing formula is as follows:
In formula, B is all branches of source program static structure Graph, and b is the number of all branch B, and p is test use cases
Any one test execution path in conjunction,Represent that there is a test execution path p covers branch Bi。
Utilize step 1) the source program static structure data that generate, use code pitching pile technology, the corresponding source to each node
Program statement carries out pitching pile.Then JUnit external member is utilized by step 3) the unit testing use-case write of middle school student operates in pitching pile
After source program on, and collect the output information of pitching pile.The source program that test case goes to is extracted from the output information of pitching pile
On node path, i.e. test execution path, last with step 2) in the testing requirement that generates compare, calculating test is covered
Lid rate;
5) test case and coverage data collect statistics;
Definition 1: testing requirement coverage rate refers to each testing requirement for source program, all test cases pair of all students
The percentage ratio that this testing requirement covers.
In formula, req is the arbitrary testing requirement of source program, and s is pupil load, psFor arbitrary test execution path of arbitrary student,Represent that there is a test execution path ps covers testing requirement req.
By step 3) the unit testing use-case write of middle school student and step 4) in be submitted to service together with the coverage data that obtains
Device, collects statistics at server end to test case and the coverage data of identical sources program;
6) visualization of source program static structure and coverage data represents;
In step 1) in use Soot framework Java source program is controlled flow point analysis time, it is intended that the control flow data of generation
For DOT formatted file (DOT is a kind of picture description language), then use the dot order in Graphviz instrument by number
SVG formatted file (SVG is the saleable vector graphics format that can use in a browser) is exported to according to file.For source journey
Each function of each class of sequence, by source program statement corresponding for each node, and the coverage rate of each testing requirement after collecting
Data, are mapped with the node on SVG controlling stream graph, represent the most in a browser;
7) single test case execution flow process in source program static structure represents;
In step 6) in select certain testing requirement, from step 5 on the figure that represents) find out all covering in the data that collect
Lid and the test case not covering this testing requirement.Then one test case of reselection, according to step 4) in the survey that collects
Example execution route data on probation, are presented in execution route on SVG figure.
A kind of Java unit testing teaching feedback method based on Program Static Analysis the most according to claim 1, it is special
Levy and be, in step 1) in, utilize program control flow analysis to obtain the static structure of source program code.Use Soot framework
Bytecode program after compiling Java source program is controlled flow point analysis, obtains the control flow data of source program, and by them
Change into general data form to store in file.
A kind of Java unit testing teaching feedback method based on Program Static Analysis the most according to claim 1, it is special
Levy and be, in step 2) in, source program testing requirement is generated by the static structure of source program code.Wherein code coverage
Testing requirement create-rule be as a testing requirement using node each in source program static structure, and the survey that branch covers
Examination demand create-rule is that every paths node each in source program static structure and its descendant node formed is as one
Testing requirement.
A kind of Java unit testing teaching feedback method based on Program Static Analysis the most according to claim 1, it is special
Levy and be, in step 3) in, student writes Java unit testing use-case in Eclipse.Program the most to be measured (source program)
The exercise question that the exercise built-in from system or teacher specify.
A kind of Java unit testing teaching feedback method based on Program Static Analysis the most according to claim 1, it is special
Levy and be, in step 4) in, collecting test use-case coverage data.Utilize step 1) the source program static structure data that generate,
Use code pitching pile technology, the corresponding source program statement of each node is carried out pitching pile.Then utilize JUnit external member by step
3) the unit testing use-case that middle school student write operates on the source program after pitching pile, and collects the output information of pitching pile.From pitching pile
Output information is extracted the node path on the source program that test case goes to, i.e. test execution path, last and step 2)
The testing requirement of middle generation compares, and calculates test coverage.
A kind of Java unit testing teaching feedback method based on Program Static Analysis the most according to claim 1, it is special
Levy and be, in step 5) in, test case and coverage data are collected statistics.By step 3) list write of middle school student
Unit's test case and step 4) in be submitted to server, at server end to identical sources program together with the coverage data that obtains
Test case and coverage data carry out collecting statistics.
A kind of Java unit testing teaching feedback method based on Program Static Analysis the most according to claim 1, it is special
Levy and be, in step 6) in, the visualization to source program static structure and coverage data represents.In step 1) middle use
When Soot framework is controlled flow point analysis to Java source program, it is intended that the control flow data of generation is that (DOT is DOT formatted file
A kind of picture description language), then use the dot order in Graphviz instrument that data file exports to SVG formatted file
(SVG is the saleable vector graphics format that can use in a browser).For each function of each class of source program, will be every
The source program statement that individual node is corresponding, and the coverage data of each testing requirement after collecting, and on SVG controlling stream graph
Node is mapped, and represents the most in a browser.
A kind of Java unit testing teaching feedback method based on Program Static Analysis the most according to claim 1, it is special
Levy and be, in step 7) in, single test case execution flow process in source program static structure represents.In step 6) middle exhibition
Select certain testing requirement on existing figure, from step 5) find out all coverings in the data that collect and do not cover this test and need
The test case asked.Then one test case of reselection, according to step 4) in the test case execution route data that collect,
Execution route is presented on SVG figure.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201610294181.2A CN106021094A (en) | 2016-04-29 | 2016-04-29 | Program static analysis based Java unit test teaching feedback method |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201610294181.2A CN106021094A (en) | 2016-04-29 | 2016-04-29 | Program static analysis based Java unit test teaching feedback method |
Publications (1)
Publication Number | Publication Date |
---|---|
CN106021094A true CN106021094A (en) | 2016-10-12 |
Family
ID=57081271
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN201610294181.2A Pending CN106021094A (en) | 2016-04-29 | 2016-04-29 | Program static analysis based Java unit test teaching feedback method |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN106021094A (en) |
Cited By (10)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN108415846A (en) * | 2018-04-19 | 2018-08-17 | 挖财网络技术有限公司 | A kind of method and apparatus generating minimal automation test use cases |
CN108845951A (en) * | 2018-08-14 | 2018-11-20 | 郑州云海信息技术有限公司 | A kind of calculation method and system of automatic test coverage rate |
CN108874656A (en) * | 2017-05-16 | 2018-11-23 | 北京京东尚科信息技术有限公司 | Code test method, device, readable storage medium storing program for executing and computer equipment |
CN109284222A (en) * | 2017-07-20 | 2019-01-29 | 阿里巴巴集团控股有限公司 | Project testing method, device and equipment in software unit, data processing system |
CN110377493A (en) * | 2018-04-12 | 2019-10-25 | 南京慕测信息科技有限公司 | A kind of unit testing use-case optimization method of code-oriented readability |
CN110502417A (en) * | 2018-05-16 | 2019-11-26 | 南京慕测信息科技有限公司 | A kind of Java test coverage analytical method based on static analysis |
CN110609787A (en) * | 2019-08-22 | 2019-12-24 | 中国电子科技集团公司第二十八研究所 | Computer software testing method based on domestic platform |
CN111524418A (en) * | 2020-03-16 | 2020-08-11 | 北京编程猫科技有限公司 | Method and device for improving graphical programming level of user |
CN112133146A (en) * | 2020-10-14 | 2020-12-25 | 天津之以科技有限公司 | Algorithm practice code execution visualization system |
CN112346994A (en) * | 2020-12-01 | 2021-02-09 | 广州品唯软件有限公司 | Test information correlation method and device, computer equipment and storage medium |
Citations (3)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN102736980A (en) * | 2012-06-29 | 2012-10-17 | 南京大学 | Random test case generation method facing Java program |
CN103198011A (en) * | 2012-01-09 | 2013-07-10 | 阿里巴巴集团控股有限公司 | Method and device for detecting file disturbance of JAVA program |
CN105335287A (en) * | 2015-10-15 | 2016-02-17 | 广东欧珀移动通信有限公司 | Automatic test method and device |
-
2016
- 2016-04-29 CN CN201610294181.2A patent/CN106021094A/en active Pending
Patent Citations (3)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN103198011A (en) * | 2012-01-09 | 2013-07-10 | 阿里巴巴集团控股有限公司 | Method and device for detecting file disturbance of JAVA program |
CN102736980A (en) * | 2012-06-29 | 2012-10-17 | 南京大学 | Random test case generation method facing Java program |
CN105335287A (en) * | 2015-10-15 | 2016-02-17 | 广东欧珀移动通信有限公司 | Automatic test method and device |
Non-Patent Citations (2)
Title |
---|
S. LI,等: "heapplicatio打ofcourse-orientedonline judge in Data Structure", 《ROBOTICS AND APPLICATIONS (ISRA),》 * |
万年红: "软件黑盒测试的方法与实践", 《计算机工程》 * |
Cited By (12)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN108874656A (en) * | 2017-05-16 | 2018-11-23 | 北京京东尚科信息技术有限公司 | Code test method, device, readable storage medium storing program for executing and computer equipment |
CN109284222A (en) * | 2017-07-20 | 2019-01-29 | 阿里巴巴集团控股有限公司 | Project testing method, device and equipment in software unit, data processing system |
CN109284222B (en) * | 2017-07-20 | 2022-03-08 | 阿里巴巴集团控股有限公司 | Software unit, project testing method, device and equipment in data processing system |
CN110377493A (en) * | 2018-04-12 | 2019-10-25 | 南京慕测信息科技有限公司 | A kind of unit testing use-case optimization method of code-oriented readability |
CN108415846A (en) * | 2018-04-19 | 2018-08-17 | 挖财网络技术有限公司 | A kind of method and apparatus generating minimal automation test use cases |
CN108415846B (en) * | 2018-04-19 | 2021-10-15 | 挖财网络技术有限公司 | Method and device for generating minimum automatic test case set |
CN110502417A (en) * | 2018-05-16 | 2019-11-26 | 南京慕测信息科技有限公司 | A kind of Java test coverage analytical method based on static analysis |
CN108845951A (en) * | 2018-08-14 | 2018-11-20 | 郑州云海信息技术有限公司 | A kind of calculation method and system of automatic test coverage rate |
CN110609787A (en) * | 2019-08-22 | 2019-12-24 | 中国电子科技集团公司第二十八研究所 | Computer software testing method based on domestic platform |
CN111524418A (en) * | 2020-03-16 | 2020-08-11 | 北京编程猫科技有限公司 | Method and device for improving graphical programming level of user |
CN112133146A (en) * | 2020-10-14 | 2020-12-25 | 天津之以科技有限公司 | Algorithm practice code execution visualization system |
CN112346994A (en) * | 2020-12-01 | 2021-02-09 | 广州品唯软件有限公司 | Test information correlation method and device, computer equipment and storage medium |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
CN106021094A (en) | Program static analysis based Java unit test teaching feedback method | |
Ullah et al. | Bloom's taxonomy: A beneficial tool for learning and assessing students’ competency levels in computer programming using empirical analysis | |
Janpla et al. | The development of problem-based learning and concept mapping using a block-based programming model to enhance the programming competency of undergraduate students in computer science | |
Hung et al. | Tenth graders’ problem-solving performance, self-efficacy, and perceptions of physics problems with different representational formats | |
Putra et al. | The implementation of ethnomathematics based-learning for students | |
Le et al. | Towards a classification for programming exercises | |
Gunes et al. | A systematic review of educational robotics studies for the period 2010–2021 | |
Tozkoparan et al. | The effect of instructional technology and material design course to teacher candidates’ gaining of technological pedagogical content knowledge competencies | |
Lo et al. | Building environmental literacy through participation in GIS and multimedia assisted field research | |
Astuti et al. | Validity and Practicality of Sangiran Site-Based Virtual Laboratory Learning Media on Evolutionary Materials to Empower Science Literacy | |
Ninasivincha-Apfata et al. | Dashboard Proposal Implemented According to an Analysis Developed on the KNIME Platform. | |
Akbayir et al. | The effect of middle school students' metacognitive awareness and logical thinking skills on success in Mathematics course | |
Lui et al. | A road map for implementing extreme programming | |
Tamami et al. | The Validation of Go-Lab Based Inquiry Learning Spaces (ILS) on Science Subject for Junior High School Student | |
Gibbs | The effect of a constructivist learning environment for field-dependent/independent students on achievement in introductory computer programming | |
Rokooei et al. | Lessons learned From a Simulation Project in Construction Education | |
Avancena et al. | Usability and pedagogical assessment of an algorithm learning tool: A case study for an introductory programming course for high school | |
Rachmatullah et al. | Identifying Indonesian upper-secondary school students’ orientations to learn science and gender effect through the use of structural equation modeling | |
Dümmel et al. | Effects of a preliminary programming course on students' performance | |
Stankov | Student model developing for intelligent tutoring systems | |
Demir et al. | Analysing the Problems of Science Teachers That They Encounter While Teaching Physics Education. | |
Carlin et al. | Educational Data Mining Using GIFT Cloud | |
Hansen | The measurement of self-efficacy | |
Wu et al. | Infusing Computational Thinking into the Accounting Curriculum-Framework and Perspectives | |
Kattou et al. | Predicting mathematical creativity |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
C06 | Publication | ||
PB01 | Publication | ||
C10 | Entry into substantive examination | ||
SE01 | Entry into force of request for substantive examination | ||
DD01 | Delivery of document by public notice | ||
DD01 | Delivery of document by public notice |
Addressee: NANJING MUCE INFORMATION TECHNOLOGY CO., LTD. Document name: the First Notification of an Office Action |
|
AD01 | Patent right deemed abandoned | ||
AD01 | Patent right deemed abandoned |
Effective date of abandoning: 20191022 |