2015-09-02 2 views
5

मैं उत्परिवर्तन परीक्षण कवरेज उत्पन्न करना चाहता हूं। मैं पीआई टेस्ट पर पीओसी कर रहा हूं लेकिन यह मेरी परीक्षा कक्षाएं नहीं ले रहा है और असफल रहा है। मैंने pom.xml में PTTest प्लगइन को कॉन्फ़िगर किया है। मैंने लक्ष्य वर्ग पैकेज नाम की जांच की है और लक्ष्य परीक्षण क्लास पैकेज नाम pom.xml फ़ाइल में सही हैं।पीटीटेस्ट विफल रहा है और उत्परिवर्तन कवरेज उत्पन्न नहीं कर रहा है

मैं त्रुटि नीचे हो रही है -

10:50:29 AM PIT >> INFO : Mutating from D:\IR\workspace\cleanup_trunk\reporterDx-service\target\classes 
10:50:29 AM PIT >> INFO : Verbose logging is disabled. If you encounter an problem please enable it before reporting an issue. 
10:50:30 AM PIT >> INFO : Sending 0 test classes to slave 
10:50:30 AM PIT >> INFO : Sent tests to slave 
10:50:30 AM PIT >> INFO : Calculated coverage in 0 seconds. 
10:50:30 AM PIT >> INFO : Created 0 mutation test units 
[INFO] ------------------------------------------------------------------------ 
[INFO] BUILD FAILURE 
[INFO] ------------------------------------------------------------------------ 
[INFO] Total time: 4.575s 
[INFO] Finished at: Wed Sep 02 10:50:30 IST 2015 
[INFO] Final Memory: 13M/244M 
[INFO] ------------------------------------------------------------------------ 
[ERROR] Failed to execute goal org.pitest:pitest-maven:1.1.4:mutationCoverage (default-cli) on project reporterDx-service: Execution default-cli of goal org.pitest:p 
itest-maven:1.1.4:mutationCoverage failed: No mutations found. This probably means there is an issue with either the supplied classpath or filters. 
[ERROR] See http://pitest.org for more details. 
[ERROR] -> [Help 1] 
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.pitest:pitest-maven:1.1.4:mutationCoverage (default-cli) on project reporterDx-ser 
vice: Execution default-cli of goal org.pitest:pitest-maven:1.1.4:mutationCoverage failed: No mutations found. This probably means there is an issue with either the 
supplied classpath or filters. 
See http://pitest.org for more details. 
     at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:225) 
     at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:153) 
     at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:145) 
     at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:84) 
     at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:59) 
     at org.apache.maven.lifecycle.internal.LifecycleStarter.singleThreadedBuild(LifecycleStarter.java:183) 
     at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:161) 
     at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:320) 
     at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:156) 
     at org.apache.maven.cli.MavenCli.execute(MavenCli.java:537) 
     at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:196) 
     at org.apache.maven.cli.MavenCli.main(MavenCli.java:141) 
     at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) 
     at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) 
     at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) 
     at java.lang.reflect.Method.invoke(Method.java:606) 
     at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:290) 
     at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:230) 
     at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:409) 
     at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:352) 
Caused by: org.apache.maven.plugin.PluginExecutionException: Execution default-cli of goal org.pitest:pitest-maven:1.1.4:mutationCoverage failed: No mutations found. 
This probably means there is an issue with either the supplied classpath or filters. 
See http://pitest.org for more details. 
     at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:110) 

यह मेरा pom.xml फ़ाइल है -

<plugin> 
    <groupId>org.pitest</groupId> 
    <artifactId>pitest-maven</artifactId> 
    <version>1.1.4</version> 
    <configuration> 
     <targetClasses> 
      <param>com.mutation.dx.pitestdemo</param> 
     </targetClasses> 
     <targetTests> 
      <param>com.mutation.dx.pitestdemo</param> 
     </targetTests> 
    </configuration> 
</plugin> 
नीचे

मेरी कक्षा जिस पर मैं उत्परिवर्तन

package com.mutation.dx.pitestdemo; 

import org.springframework.beans.factory.annotation.Autowired; 

public class PIDemoImpl implements PIDemo { 

    @Autowired 
    private PIDemoDao piDemoDao; 

    @Override 
    public PIDto getPIDetails(String name, int firstNumber,int secondNumber) { 
     int thirdNumber = firstNumber * secondNumber; 
     PIDomain piDomain = piDemoDao.getPIDomain(name, thirdNumber); 
     if(piDomain != null) { 
      PIDto piDto = new PIDto(); 
      piDto.setName(piDomain.getName()); 
      int result = piDomain.getX() + piDomain.getY(); 
      if(result >= 0) { 
       piDto.setResult(result); 
      } 
      return piDto; 
     } 
     return null; 
    } 
} 

उत्पन्न करना चाहते है नीचे मेरी टेस्ट क्लास है-

package com.mutation.dx.pitestdemo; 

import org.junit.Assert; 
import org.junit.Test; 
import org.junit.runner.RunWith; 
import org.mockito.InjectMocks; 
import org.mockito.Mock; 
import static org.mockito.Mockito.when; 
import static org.mockito.Mockito.verify; 
import org.mockito.runners.MockitoJUnitRunner; 

import com.mutation.dx.pitestdemo.PIDemoImpl; 

@RunWith(MockitoJUnitRunner.class) 
public class PIDemoImplTest { 
    @Mock 
    private PIDemoDao piDemoDao; 

    @InjectMocks 
    PIDemoImpl piDemoImpl; 

    @Test 
    public void getPIDetailsTest(){ 
     String name = "Persistent"; 
     int firstNumber = 0; 
     int secondNumber = 10; 
     int thirdNumber = 0; 
     PIDomain piDomain = new PIDomain(); 
     piDomain.setName(name); 
     piDomain.setX(2); 
     piDomain.setY(2); 
     when(piDemoDao.getPIDomain(name, thirdNumber)).thenReturn(piDomain); 
     PIDto piDto = piDemoImpl.getPIDetails(name , firstNumber, secondNumber); 
     Assert.assertNotNull(piDto); 
     Assert.assertEquals(piDto.getName(),name); 
     verify(piDemoDao).getPIDomain(name, thirdNumber); 
    } 
} 

मैं वस्तुओं को नकल करने के लिए मॉकिटो का उपयोग कर रहा हूं।

उत्तर

6

आपके फ़िल्टर सही नहीं दिख रहे हैं। Pitest ग्लोब की उम्मीद है कि प्रत्येक वर्ग के पूरी तरह से योग्य नाम के खिलाफ मिलान कर रहे हैं।

com.mutation.dx.pitestdemo

के बजाय

com.mutation.dx.pitestdemo.*

* wilcard तो पैकेज में सभी वर्गों से मेल खाना चाहिए की कोशिश करो।

1.2.0 targetClasses और targetTests के रूप में आमतौर पर मैवेन से चलने पर निर्दिष्ट होने की आवश्यकता नहीं होती है - पिटस्ट अब परियोजना को स्कैन करेगा और स्वचालित रूप से यह निर्धारित करेगा कि परियोजना में कौन से पैकेज परिभाषित किए गए हैं।

+0

धन्यवाद हेनरी। आपके समाधान ने मेरी समस्या हल की। –

संबंधित मुद्दे