The mutation test is to compare the results of unit test cases by changing the source code of the tested object to determine the quality of unit test cases. You are not very familiar with it. You can only give a rough description.
There are very few materials for online variant tests, most of which are academic papers.
The Princess of the mutation test is Mujava and muclipse. muclipse is based on Mujava and is integrated with Eclipse plug-ins.
Mujava http://cs.gmu.edu /~ Offutt/Mujava/
Muclipse http://muclipse.sourceforge.net/index.php
According to the official website step by step, I did not succeed. I changed the parameters one by one and finally got the result. So I wrote this article to reduce the research time.
1. Install muclipse
Because the download URL provided on the official website cannot be opened, you have to find an Edu online. ncsu. download muclipse_1.3.0.jar, put it in the eclipse plugins directory, and restart eclipse. Even if it is installed, this installation method of eclipse is really simple.
2. Prepared Test Cases
Package demo1;
Public class example {
Public int multiply (int A, int B ){
Return a * B;
}
}
Package demo1;
Public class exampletest {
Public void setup () throws exception {
}
Public void teardown () throws exception {
}
Public int testmultiply ()
{
Example EX = new example ();
Return ex. Multiply (1, 1 );
}
}
3. Configure the environment
1. Create or import a project, download the extendedoj. jar package, and import it to libraries
Right-click Project name-> properties-> JAVA build path-> libraries-> Add external jars, select it and click OK
650) This. width = 650; "src =" http://img.blog.csdn.net/20140626151614031? Watermark/2/text/plain =/font/5a6l5l2t/fontsize/400/fill/i0jbqkfcma =/dissolve/70/gravity/center "/>
In source tab, you can modify the Output Folder, which is the address of the compiled. Class file. The default value is bin.
650) This. width = 650; "src =" http://img.blog.csdn.net/20140626151642718? Watermark/2/text/plain =/font/5a6l5l2t/fontsize/400/fill/i0jbqkfcma =/dissolve/70/gravity/center "/>
2. compile the project. You can view the compiled. Class file in the bin.
Right-click the project name and select build project.
3. Generate the variant source file
1. Right-click the project name and choose run as> RUN configuration...
Configure deriectories
650) This. width = 650; "src =" http://img.blog.csdn.net/20140626151701218? Watermark/2/text/plain =/font/5a6l5l2t/fontsize/400/fill/i0jbqkfcma =/dissolve/70/gravity/center "/>
Configure Operator
650) This. width = 650; "src =" http://img.blog.csdn.net/20140626151709265? Watermark/2/text/plain =/font/5a6l5l2t/fontsize/400/fill/i0jbqkfcma =/dissolve/70/gravity/center "/>
Click Run to generate the variant Code. For details, see the result directory.
4. display the mutation result in eclipse
Windows-> show View
650) This. width = 650; "src =" http://img.blog.csdn.net/20140626151729093? Watermark/2/text/plain =/font/5a6l5l2t/fontsize/400/fill/i0jbqkfcma =/dissolve/70/gravity/center "/>
Note that only the method-level has mutations.
650) This. width = 650; "src =" http://img.blog.csdn.net/20140626152038703? Watermark/2/text/plain =/font/5a6l5l2t/fontsize/400/fill/i0jbqkfcma =/dissolve/70/gravity/center "/>
650) This. width = 650; "src =" http://img.blog.csdn.net/20140626152049093? Watermark/2/text/plain =/font/5a6l5l2t/fontsize/400/fill/i0jbqkfcma =/dissolve/70/gravity/center "/>
5. Execute Test
Configure muclipse test: Right-click the project name and choose run as> RUN configuration.
650) This. width = 650; "src =" http://img.blog.csdn.net/20140626152107984? Watermark/2/text/plain =/font/5a6l5l2t/fontsize/400/fill/i0jbqkfcma =/dissolve/70/gravity/center "/>
Configure Testing Operation: because the production variant instance only has method level, do not check the class-level. Otherwise, an error occurs. Click RUN button
650) This. width = 650; "src =" http://img.blog.csdn.net/20140626152826156? Watermark/2/text/plain =/font/5a6l5l2t/fontsize/400/fill/i0jbqkfcma =/dissolve/70/gravity/center "/>
6. view the results
Click Refresh
650) This. width = 650; "src =" http://img.blog.csdn.net/20140626152514296? Watermark/2/text/plain =/font/5a6l5l2t/fontsize/400/fill/i0jbqkfcma =/dissolve/70/gravity/center "/>
This article is from the "love work, love life" blog. For more information, contact the author!