2012-07-27 1 views
1

J'ai écrit mon projet maven dans Netbeans.J'ai écrit des tests pour mon projet (dao, service ..). Tous les tests ont raison, mais quand je construis ou tester mon projet Maven montre qu'il n'y a pas de tests à l'aide compile.I'm maven-plugin-Surefire, donc l'inclure à la pom.xml:J'ai des problèmes avec tester mon projet par maven-surefire-plugin

<plugin> 
    <groupId>org.apache.maven.plugins</groupId> 
    <artifactId>maven-surefire-plugin</artifactId> 
    <version>2.10</version> 

       <dependencies> 
        <dependency> 
         <groupId>org.apache.maven.surefire</groupId> 
         <artifactId>surefire-junit47</artifactId> 
         <version>2.10</version>       
        </dependency> 
       </dependencies> 

       <configuration> 
        <testFailureIgnore>true</testFailureIgnore> 
        <reportsDirectory>${project.build.directory}/surefire-reports</reportsDirectory> 
       </configuration> 

Je pense que quelque chose de mal avec surefire-plugin ..

Cest:

Scanning for projects... 

------------------------------------------------------------------------ 
Building Employeers 1.0.0-BUILD-SNAPSHOT 
------------------------------------------------------------------------ 

[aspectj:compile] 

[resources:resources] 
[debug] execute contextualize 
Using 'UTF-8' encoding to copy filtered resources. 
Copying 4 resources 

[compiler:compile] 
Nothing to compile - all classes are up to date 

[aspectj:test-compile] 

[resources:testResources] 
[debug] execute contextualize 
Using 'UTF-8' encoding to copy filtered resources. 
Copying 1 resource 

[compiler:testCompile] 
Nothing to compile - all classes are up to date 

[surefire:test] 
Surefire report directory: C:\Users\Администратор\Documents\NetBeansProjects\Employeers\target\surefire-reports 
Using configured provider org.apache.maven.surefire.junitcore.JUnitCoreProvider 

------------------------------------------------------- 
T E S T S 
------------------------------------------------------- 
Error: An unexpected error occurred while trying to open file C:\Users\?????????????\Documents\NetBeansProjects\Employeers\target\surefire\surefirebooter472050683580306804.jar 

Results : 

Tests run: 0, Failures: 0, Errors: 0, Skipped: 0 


[war:war] 
Packaging webapp 
Assembling webapp [Employeers] in [C:\Users\Администратор\Documents\NetBeansProjects\Employeers\target\Employeers-1.0.0-BUILD-SNAPSHOT] 
Processing war project 
Copying webapp resources [C:\Users\Администратор\Documents\NetBeansProjects\Employeers\src\main\webapp] 
Webapp assembled in [590 msecs] 
Building war: C:\Users\Администратор\Documents\NetBeansProjects\Employeers\target\Employees.war 
Warning: selected war files include a WEB-INF/web.xml which will be ignored 
(webxml attribute is missing from war task, or ignoreWebxml attribute is specified as 'true') 
------------------------------------------------------------------------ 
BUILD SUCCESS 
------------------------------------------------------------------------ 
Total time: 5.258s 
Finished at: Fri Jul 27 19:47:07 EEST 2012 
Final Memory: 6M/16M 
------------------------------------------------------------------------ 

Répondre

1

Le nom d'utilisateur avec des caractères cyrilliques pourraient être impliqués.

Alors que le plugin indique d'abord le répertoire suivant:

C:\Users\Администратор\Documents\NetBeansProjects\Employeers\target\surefire-reports 

il se réfère plus tard comme les éléments suivants (notez les points d'interrogation):

C:\Users\?????????????\Documents\NetBeansProjects\Employeers\target\surefire\surefirebooter472050683580306804.jar 
+0

Merci beaucoup Orique.Y at-il des solutions possibles sans changer de répertoire? – ema

+0

Difficile à dire. Ressemble à un problème d'encodage. Avez-vous défini UTF-8 comme encodage par défaut pour votre projet? [link] (http://maven.apache.org/general.html#encoding-warning). S'il vous plaît poster pom.xml alors peut-être que d'autres peuvent vous aider. – orique

+0

UTF-8 est défini par défaut – ema

1

C'est mon pom:

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
     xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> 
    <modelVersion>4.0.0</modelVersion> 
    <groupId>com.mycompany</groupId> 
    <artifactId>Employeers</artifactId> 

    <version>1.0.0-BUILD-SNAPSHOT</version> 
    <packaging>war</packaging> 

    <name>Employeers</name> 

    <properties> 
     <endorsed.dir>${project.build.directory}/endorsed</endorsed.dir> 
     <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> 
     <java-version>1.7</java-version> 
     <org.aspectj-version>1.6.9</org.aspectj-version> 
     <org.slf4j-version>1.5.10</org.slf4j-version> 
     <org.springframework.roo-version>1.0.2.RELEASE</org.springframework.roo-version> 

    </properties> 

    <dependencies> 

     <!--    SERVLET         --> 
     <dependency> 
      <groupId>javax.servlet</groupId> 
      <artifactId>servlet-api</artifactId> 
      <version>2.5</version> 
     </dependency> 
     <dependency> 
      <groupId>javax.transaction</groupId> 
      <artifactId>jta</artifactId> 
      <version>1.1</version> 
     </dependency> 
     <dependency> 
      <groupId>javax.xml.bind</groupId> 
      <artifactId>jaxb-api</artifactId> 
      <version>2.1</version> 
     </dependency> 
     <dependency> 
      <groupId>com.sun.xml.bind</groupId> 
      <artifactId>jaxb-impl</artifactId> 
      <version>2.1.3</version> 
     </dependency> 
     <dependency> 
      <groupId>javax.servlet.jsp</groupId> 
      <artifactId>jsp-api</artifactId> 
      <version>2.2</version> 
     </dependency> 
     <!--            --> 
     <dependency> 
      <groupId>javax.persistence</groupId> 
      <artifactId>persistence-api</artifactId> 
      <version>1.0</version> 
     </dependency> 
     <dependency> 
      <groupId>javax.servlet</groupId> 
      <artifactId>jstl</artifactId> 
      <version>1.2</version> 
     </dependency> 
     <dependency> 
      <groupId>org.hibernate</groupId> 
      <artifactId>ejb3-persistence</artifactId> 
      <version>1.0.1.GA</version> 
     </dependency> 
     <!-- Hibernate          --> 
     <dependency> 
      <groupId>org.hibernate</groupId> 
      <artifactId>hibernate</artifactId> 
      <version>3.2.6.ga</version> 
     </dependency> 
     <dependency> 
      <groupId>org.hibernate</groupId> 
      <artifactId>hibernate-core</artifactId> 
      <version>3.3.2.GA</version> 
     </dependency> 
     <dependency> 
      <groupId>org.hibernate</groupId> 
      <artifactId>hibernate-annotations</artifactId> 
      <version>3.4.0.GA</version> 
     </dependency> 
     <dependency> 
      <groupId>org.hibernate</groupId> 
      <artifactId>hibernate-commons-annotations</artifactId> 
      <version>3.2.0.Final</version> 
     </dependency> 
     <!-- Support of transaction --> 
     <dependency> 
      <groupId>org.springframework</groupId> 
      <artifactId>spring-tx</artifactId> 
      <version>3.0.6.RELEASE</version> 
     </dependency> 
     <dependency> 
      <groupId>org.springframework</groupId> 
      <artifactId>spring-orm</artifactId> 
      <version>3.0.6.RELEASE</version> 
     </dependency> 
     <dependency> 
      <groupId>org.springframework</groupId> 
      <artifactId>spring-beans</artifactId> 
      <version>3.0.6.RELEASE</version> 
     </dependency> 
     <dependency> 
      <groupId>org.springframework</groupId> 
      <artifactId>spring-context</artifactId> 
      <version>3.0.6.RELEASE</version> 
      <exclusions> 
       <!-- Exclude Commons Logging in favor of SLF4j --> 
       <exclusion> 
        <groupId>commons-logging</groupId> 
        <artifactId>commons-logging</artifactId> 
       </exclusion> 
     </exclusions> 
     </dependency> 

     <!--      ROO     --> 
     <dependency> 
      <groupId>org.springframework.roo</groupId> 
      <artifactId>org.springframework.roo.annotations</artifactId> 
      <version>${org.springframework.roo-version}</version> 
      <scope>provided</scope> 
     </dependency> 

     <!--      Aspectj     --> 
     <dependency> 
      <groupId>org.aspectj</groupId> 
      <artifactId>aspectjrt</artifactId> 
      <version>${org.aspectj-version}</version> 
     </dependency> 
     <dependency> 
         <groupId>org.aspectj</groupId> 
         <artifactId>aspectjweaver</artifactId> 
         <version>1.6.10</version> 
     </dependency> 
     <!--      LOGGING     --> 
     <dependency> 
      <groupId>org.slf4j</groupId> 
      <artifactId>slf4j-api</artifactId> 
      <version>${org.slf4j-version}</version> 
     </dependency> 
     <dependency> 
      <groupId>org.slf4j</groupId> 
      <artifactId>jcl-over-slf4j</artifactId> 
      <version>${org.slf4j-version}</version> 
      <scope>runtime</scope> 
     </dependency> 
     <dependency> 
      <groupId>org.slf4j</groupId> 
      <artifactId>slf4j-log4j12</artifactId> 
      <version>${org.slf4j-version}</version> 
      <scope>runtime</scope> 
     </dependency> 
     <dependency> 
      <groupId>log4j</groupId> 
      <artifactId>log4j</artifactId> 
      <version>1.2.15</version> 
      <exclusions> 
       <exclusion> 
        <groupId>javax.mail</groupId> 
        <artifactId>mail</artifactId> 
       </exclusion> 
       <exclusion> 
        <groupId>javax.jms</groupId> 
        <artifactId>jms</artifactId> 
       </exclusion> 
       <exclusion> 
        <groupId>com.sun.jdmk</groupId> 
        <artifactId>jmxtools</artifactId> 
       </exclusion> 
       <exclusion> 
        <groupId>com.sun.jmx</groupId> 
        <artifactId>jmxri</artifactId> 
       </exclusion> 
      </exclusions> 
      <scope>runtime</scope> 
     </dependency> 

      <!--       @Inject        --> 
    <dependency> 
     <groupId>javax.inject</groupId> 
     <artifactId>javax.inject</artifactId> 
     <version>1</version> 
    </dependency> 

      <!--       TEST         --> 
     <dependency> 
      <groupId>junit</groupId> 
      <artifactId>junit</artifactId> 
      <version>4.10</version> 
      <scope>test</scope> 
     </dependency> 
     <dependency> 
      <groupId>org.easymock</groupId> 
      <artifactId>easymock</artifactId> 
      <version>2.4</version> 
     </dependency> 
     <dependency> 
      <groupId>org.springframework</groupId> 
      <artifactId>spring-test</artifactId> 
      <version>3.0.6.RELEASE</version> 
     </dependency>  

      <!---->  
     <dependency> 
      <groupId>mysql</groupId> 
      <artifactId>mysql-connector-java</artifactId> 
      <version>5.1.13</version> 
     </dependency> 
     <dependency> 
      <groupId>org.springframework</groupId> 
      <artifactId>spring-web</artifactId> 
      <version>3.0.6.RELEASE</version> 
     </dependency> 
     <!--      Security     --> 
     <dependency> 
      <groupId>org.springframework.security</groupId> 
      <artifactId>spring-security-web</artifactId> 
      <version>3.0.6.RELEASE</version> 
     </dependency> 
     <dependency> 
      <groupId>org.springframework.security</groupId> 
      <artifactId>spring-security-config</artifactId> 
      <version>3.0.6.RELEASE</version> 
     </dependency> 
     <dependency> 
      <groupId>org.springframework.security</groupId> 
      <artifactId>spring-security-core</artifactId> 
      <version>3.0.6.RELEASE</version> 
     </dependency> 
     <!--     Spring mvc       --> 
     <dependency> 
      <groupId>org.springframework</groupId> 
      <artifactId>spring-webmvc</artifactId> 
      <version>3.0.6.RELEASE</version> 
      <type>jar</type> 
     </dependency> 

     <dependency> 
      <groupId>org.hibernate</groupId> 
      <artifactId>hibernate-validator</artifactId> 
      <version>4.0.2.GA</version> 
     </dependency> 
     <dependency> 
      <groupId>javax.validation</groupId> 
      <artifactId>validation-api</artifactId> 
      <version>1.0.0.GA</version> 
     </dependency> 

    </dependencies> 


    <build> 
     <plugins> 

      <plugin> 
       <groupId>org.apache.maven.plugins</groupId> 
       <artifactId>maven-compiler-plugin</artifactId> 
       <version>2.3.2</version> 
       <configuration> 
        <source>1.7</source> 
        <target>1.7</target> 
        <compilerArguments> 
         <endorseddirs>${endorsed.dir}</endorseddirs> 
        </compilerArguments> 
       </configuration> 
      </plugin> 

      <plugin> 
       <groupId>org.apache.maven.plugins</groupId> 
       <artifactId>maven-war-plugin</artifactId> 
       <version>2.1.1</version> 
       <configuration> 
        <warName>Employees</warName> 
       </configuration> 
      </plugin> 

      <plugin> 
       <groupId>org.apache.maven.plugins</groupId> 
       <artifactId>maven-dependency-plugin</artifactId> 
       <version>2.1</version> 
       <executions> 
        <execution> 
         <phase>install</phase> 
         <goals> 
          <goal>sources</goal> 
         </goals> 
         <!-- 
         <configuration> 
          <outputDirectory>${endorsed.dir}</outputDirectory> 
          <silent>true</silent> 
          <artifactItems> 
           <artifactItem> 
            <groupId>javax</groupId> 
            <artifactId>javaee-endorsed-api</artifactId> 
            <version>6.0</version> 
            <type>jar</type> 
           </artifactItem> 
          </artifactItems> 
         </configuration> 
         --> 
        </execution> 
       </executions> 
      </plugin> 

      <plugin> 
       <groupId>org.codehaus.mojo</groupId> 
       <artifactId>aspectj-maven-plugin</artifactId> 
       <version>1.2</version> 
       <dependencies> 
        <dependency> 
         <groupId>org.aspectj</groupId> 
         <artifactId>aspectjrt</artifactId> 
         <version>${org.aspectj-version}</version> 
        </dependency> 
        <dependency> 
         <groupId>org.aspectj</groupId> 
         <artifactId>aspectjtools</artifactId> 
         <version>${org.aspectj-version}</version> 
        </dependency> 

       </dependencies> 

       <executions> 
        <execution> 
         <goals> 
          <goal>compile</goal> 
          <goal>test-compile</goal> 
         </goals> 
        </execution> 
       </executions> 
       <configuration> 
        <outxml>true</outxml> 
        <source>${java-version}</source> 
        <target>${java-version}</target> 
       </configuration> 
      </plugin> 

      <plugin> 
       <groupId>org.apache.maven.plugins</groupId> 
       <artifactId>maven-surefire-plugin</artifactId> 
       <version>2.10</version> 
       <dependencies> 
        <dependency> 
         <groupId>org.apache.maven.surefire</groupId> 
         <artifactId>surefire-junit47</artifactId> 
         <version>2.10</version> 

        </dependency> 
       </dependencies> 
       <configuration> 
        <testFailureIgnore>true</testFailureIgnore> 
        <reportsDirectory>${project.build.directory}/surefire-reports</reportsDirectory> 
       </configuration> 

      </plugin> 

      <plugin> 
       <groupId>org.codehaus.mojo</groupId> 
       <artifactId>tomcat-maven-plugin</artifactId> 
       <version>1.0-beta-1</version> 

      </plugin> 

     </plugins> 
    </build> 


    <repositories> 
       <!-- For developing against latest Spring milestones --> 
     <repository> 
      <id>org.springframework.maven.milestone</id> 
      <name>Spring Maven Milestone Repository</name> 
      <url>http://maven.springframework.org/milestone</url> 
      <snapshots><enabled>false</enabled></snapshots> 
     </repository> 
       <!-- For testing against latest Spring snapshots --> 
     <repository> 
         <id>org.springframework.maven.snapshot</id> 
         <name>Spring Maven Snapshot Repository</name> 
         <url>http://maven.springframework.org/snapshot/</url> 
         <snapshots><enabled>true</enabled></snapshots> 
         <releases><enabled>false</enabled></releases> 
     </repository> 
     <repository> 
      <url>http://repo1.maven.org/maven2/</url> 
      <id>junit_4</id> 
      <layout>default</layout> 
      <name>Repository for library Library[junit_4]</name> 
     </repository> 
    </repositories> 

</project>