2016-04-05 13 views
8

staram od kilku dni, aby rozwiązać następujący błąd, ale nie jestem w stanie go :(Nie można wykonać celu org.apache.maven.plugins: maven-surefire-plugin: 2.12: test (test domyślny) w projekcie.

plik pom.xml mojego modułu jest rozwiązać:

<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> 
<parent> 
<artifactId>junitcategorizer</artifactId> 
<groupId>com.topdesk.test.junitcategorizer</groupId> 
<version>0.0.1-SNAPSHOT</version> 
<relativePath>..</relativePath> 
</parent> 
<artifactId>junitcategorizer.instrument</artifactId> 
<name>JUnitCategorizer InstrumentationAgent</name> 
<description>The agent used to instrument the called Java classes</description> 
<dependencies> 
<dependency> 
    <groupId>org.ow2.asm</groupId> 
    <artifactId>asm-commons</artifactId> 
    <version>4.0</version> 
</dependency> 
<dependency> 
    <groupId>junit</groupId> 
    <artifactId>junit</artifactId> 
    <version>4.10</version> 
</dependency> 
</dependencies> 
<build> 
<plugins> 
    <plugin> 
    <groupId>org.apache.maven.plugins</groupId> 
    <artifactId>maven-jar-plugin</artifactId> 
    <configuration> 
     <archive> 
     <manifest> 
      <addClasspath>true</addClasspath> 
     </manifest> 
     <manifestEntries> 
      <Premain-Class>com.topdesk.junitcategorizer.instrument.InstrumentationAgent</Premain-Class> 
      <Agent-Class>com.topdesk.junitcategorizer.instrument.InstrumentationAgent</Agent-Class> 
      <Can-Redefine-Classes>true</Can-Redefine-Classes> 
      <Can-Retransform-Classes>true</Can-Retransform-Classes> 
      <Boot-Class-Path>${project.artifactId}-${project.version}.jar</Boot-Class-Path> 
      <Can-Set-Native-Method-Prefix>true</Can-Set-Native-Method-Prefix> 
     </manifestEntries> 
     </archive> 
    </configuration> 
    </plugin> 
    <plugin> 
    <groupId>org.apache.maven.plugins</groupId> 
    <artifactId>maven-shade-plugin</artifactId> 
    <version>1.5</version> 
    <executions> 
     <execution> 
     <phase>package</phase> 
     <goals> 
      <goal>shade</goal> 
     </goals> 
     <configuration> 
      <artifactSet> 
      <includes> 
       <include>org.ow2.asm:*</include> 
      </includes> 
      </artifactSet> 
      <relocations> 
      <relocation> 
       <pattern>org.objectweb.asm</pattern> 
       <shadedPattern>org.shaded.asm</shadedPattern> 
      </relocation> 
      </relocations> 
     </configuration> 
     </execution> 
    </executions> 
    </plugin> 
</plugins> 
</build> 
</project> 

otrzymuję następujący błąd :

[ERROR] Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2. 
12:test (default-test) on project junitcategorizer.instrument: There are test failures. 
[ERROR] 
[ERROR] Please refer to D:\Masters\thesis related papers and tools\junitcategorizer\junitcategorizer.instrument\target\surefire-reports for the individual test results. 
[ERROR] -> [Help 1] 
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.12:test (default-test) on project junitcategorizer.instrument: There are test failures. 

Please refer to D:\Masters\thesis related papers and tools\junitcategorizer\junitcategorizer.instrument\target\surefire-reports for the individual test results. 

    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:212) 
    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:116) 
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:80) 
    at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build(SingleThreadedBuilder.java:51) 
    at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:120) 
    at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:347) 
    at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:154) 
    at org.apache.maven.cli.MavenCli.execute(MavenCli.java:582) 
    at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:214) 
    at org.apache.maven.cli.MavenCli.main(MavenCli.java:158) 
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) 
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) 
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) 
    at java.lang.reflect.Method.invoke(Method.java:497) 
    at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:289) 
    at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:229) 
    at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:415) 
    at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:356) 
    Caused by: org.apache.maven.plugin.MojoFailureException: There are test failures. 

    Please refer to D:\Masters\thesis related papers and tools\junitcategorizer\junitcategorizer.instrument\target\surefire-reports for the individual test results. 

    at org.apache.maven.plugin.surefire.SurefireHelper.reportExecution(SurefireHelper.java:83) 
    at org.apache.maven.plugin.surefire.SurefirePlugin.writeSummary(SurefirePlugin.java:673) 
    at org.apache.maven.plugin.surefire.SurefirePlugin.handleSummary(SurefirePlugin.java:647) 
    at org.apache.maven.plugin.surefire.AbstractSurefireMojo.executeAfterPreconditionsChecked(AbstractSurefireMojo.java:137) 
    at org.apache.maven.plugin.surefire.AbstractSurefireMojo.execute(AbstractSurefireMojo.java:98) 
    at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:132) 
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:208) 
    ... 19 more 
    [ERROR] 
    [ERROR] Re-run Maven using the -X switch to enable full debug logging. 

próbowałem następujące, ale nie pomogło:

  1. mvn Zależność :: drzewo
  2. mvn czystej instalacji -U lub prawym przyciskiem myszy na "projektu" Idź do "Maven" >> "Update"

Proszę mi pomóc!

+0

miałem podobny problem, moja odpowiedź tutaj: http://stackoverflow.com/a/41666587/2230045 – Spen

Odpowiedz

6

Dodaj do pom:

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

W kodzie błędu nie znalazł surefire plugin więc dodać to

+0

Dzięki za odpowiedź! ale to mi nie pomogło, ponieważ ten plik pom jest z modułu, a macierzysty plik pom ma tę wtyczkę. – Srinu

+0

To nie jest problem! – Spen

+1

to jest :) nawet jeśli dodajesz ' true ' rozwiązuje problem, lepiej odpowiada na problem, a nie komentuje zadaniami idiota – Hohenheim

0

mam dokładnie taką samą StackTrace gdy testy zawodzą. W górnej części ekranu powinny pojawić się komunikaty identyfikujące niesprawne klasy testowe. Lub przejdź do

D:\Masters\thesis related papers and tools\junitcategorizer\junitcategorizer.instrument\target\surefire-reports 

i przejrzyj raporty o błędach. Napraw problemy, a twoja kompilacja jest w porządku.

Dobra wiadomość: Twoje poms wydają się być w porządku, Maven może kompilować i wykonywać testy.

0

try w cmd: mvn clean install -Dskiptests=true

że będziemy pomijać wszystkie badanej jednostki. Może być Będzie dobrze dla ciebie działać.

+0

To się nie zmieniło cokolwiek dla mnie. – Spen

2

Sprawdź swoje pliki testowe. Musisz usunąć wszystkie błędy plików testowych w swoim projekcie i spróbować Wyczyść i skompiluj.

+0

Punktem badań NIE jest to, że przeszkadzają one w budowaniu projektu ... – Spen

0

który pracował dla mnie,

prawym przyciskiem myszy na projekt -> "Uruchom jako Maven Test". Spowoduje to automatyczne pobranie brakujących wtyczek, a następnie kliknięcie prawym przyciskiem myszy na projekt -> "Zaktualizuj projekt Maven" - usunie błąd.

0

Spróbuj tego:

mvn zależność :: drzewo w terminalu lub Command Prompt

Powodzenia ;-)

+0

co to jest i jak to zrobić w projekcie IDE Eclipse? @ A.EI –

2

Jest to rodzaj niepowodzenia testu. @SpringBootApplication adnotacja zawiera te konfiguracje.

1) @Configuration

2) @ComponentScan

3) @EnableAutoConfiguration

@EnableAutoConfiguration jest przyczyną tego błędu. Spowoduje to automatyczną konfigurację aplikacji zgodnie z zależnościami w pom.xml

Jako przykład, gdy masz zależność danych źródłowych-jpa w pom, spróbujesz dodać konfigurację do aplikacji, patrząc na plik application.properties dla danych źródło. Musisz więc dodać źródło danych, aby to rozwiązać.

dla MySQL:

spring.jpa.hibernate.ddl-auto=create 
spring.datasource.url=jdbc:mysql://localhost/lahiru 
spring.datasource.username=root 
spring.datasource.password= 

Albo

Można ukryć ten omijając testowania.

mvn install -DskipTests 

Więcej details.

0

Jeśli istnieją błędy testowe prostu pomiń je

mvn install -DskipTests 

ale gorąco polecam mocowania test pierwszy.

1

HI Możesz spróbować dodać poniższe elementy do POM, a następnie użyć mvn clean compile, a następnie mvn install.

<!-- https://mvnrepository.com/artifact/junit/junit --> 
<dependency> 
    <groupId>junit</groupId> 
    <artifactId>junit</artifactId> 
    <version>4.12</version> 
    <scope>test</scope> 
</dependency> 
Powiązane problemy