Maven Test werden nicht ausgeführt . Junit . Maven . Surefire . Eclipse

pixelhead

Aktives Mitglied
Hallo zusammen,

schon länger suche ich nach einer Lösung und finde schlicht nichts. Es gab auch sehr ähnliche Fragestellungen (auch hier), aber die genannten Lösungen passen bei mir nicht oder ich verstehe sie evtl. nicht. Nun also zur Problemstellung ...

Ich habe drei kleine Testklassen und sie sind in Eclipse via Kontextmenü "Run As" -> "JUnit Test" ausführbar.

Via Kontextmenü "Run As" -> "Maven test" auf dem Projektordner funktioniert dies nicht. Der Build läuft durch, aber es werden keine Tests ausgeführt. Drei sind vorhanden.

Hier der Durchlauf:

[CODE lang="java" title="Maven test via Kontextmenü"][INFO] Scanning for projects...
[INFO]
[INFO] ----------------< de.condingsolo:SeleniumMavenProjekt1 >----------------
[INFO] Building SeleniumMavenProjekt1 0.0.1-SNAPSHOT
[INFO] --------------------------------[ jar ]---------------------------------
[INFO]
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ SeleniumMavenProjekt1 ---
[WARNING] Using platform encoding (Cp1252 actually) to copy filtered resources, i.e. build is platform dependent!
[INFO] Copying 0 resource
[INFO]
[INFO] --- maven-compiler-plugin:3.1:compile (default-compile) @ SeleniumMavenProjekt1 ---
[INFO] Nothing to compile - all classes are up to date
[INFO]
[INFO] --- maven-resources-plugin:2.6:testResources (default-testResources) @ SeleniumMavenProjekt1 ---
[WARNING] Using platform encoding (Cp1252 actually) to copy filtered resources, i.e. build is platform dependent!
[INFO] Copying 0 resource
[INFO]
[INFO] --- maven-compiler-plugin:3.1:testCompile (default-testCompile) @ SeleniumMavenProjekt1 ---
[INFO] Changes detected - recompiling the module!
[WARNING] File encoding has not been set, using platform encoding Cp1252, i.e. build is platform dependent!
[INFO] Compiling 3 source files to C:\4ma\software\Eclipse\eclipse_workspace\SeleniumMavenProjekt1\target\test-classes
[INFO]
[INFO] --- maven-surefire-plugin:3.0.0-M5:test (default-test) @ SeleniumMavenProjekt1 ---
[INFO] Downloading from central: https://repo.maven.apache.org/maven2/org/junit/platform/junit-platform-launcher/1.4.0/junit-platform-launcher-1.4.0.jar
[INFO]
[INFO] -------------------------------------------------------
[INFO] T E S T S
[INFO] -------------------------------------------------------
[INFO]
[INFO] Results:
[INFO]
[INFO] Tests run: 0, Failures: 0, Errors: 0, Skipped: 0
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 4.596 s
[INFO] Finished at: 2021-06-22T17:33:33+02:00
[INFO] ------------------------------------------------------------------------
[/CODE]

Via Terminal mit

[CODE lang="java" title="mvn test Command"]mvn test[/CODE]

oder auch

[CODE lang="java" title="mvn Command"]mvn -Dtest=TestAufrufBrowserFirefox -e test [/CODE]

kommt es zum Feher (vollständige Fehlermeldung):

[CODE lang="java" title="mvn -Dtest=TestAufrufBrowserFirefox -e test Command"]C:\Users\vorname.nachname>mvn -Dtest=TestAufrufBrowserFirefox -e test
[INFO] Error stacktraces are turned on.
[INFO] Scanning for projects...
[INFO]
[INFO] ----------------< de.condingsolo:SeleniumMavenProjekt1 >----------------
[INFO] Building SeleniumMavenProjekt1 0.0.1-SNAPSHOT
[INFO] --------------------------------[ jar ]---------------------------------
[INFO]
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ SeleniumMavenProjekt1 ---
[WARNING] Using platform encoding (Cp1252 actually) to copy filtered resources, i.e. build is platform dependent!
[INFO] skip non existing resourceDirectory C:\Users\marc.schmidt\src\main\resources
[INFO]
[INFO] --- maven-compiler-plugin:3.1:compile (default-compile) @ SeleniumMavenProjekt1 ---
[INFO] No sources to compile
[INFO]
[INFO] --- maven-resources-plugin:2.6:testResources (default-testResources) @ SeleniumMavenProjekt1 ---
[WARNING] Using platform encoding (Cp1252 actually) to copy filtered resources, i.e. build is platform dependent!
[INFO] skip non existing resourceDirectory C:\Users\marc.schmidt\src\test\resources
[INFO]
[INFO] --- maven-compiler-plugin:3.1:testCompile (default-testCompile) @ SeleniumMavenProjekt1 ---
[INFO] No sources to compile
[INFO]
[INFO] --- maven-surefire-plugin:3.0.0-M5:test (default-test) @ SeleniumMavenProjekt1 ---
[INFO] No tests to run.
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 1.549 s
[INFO] Finished at: 2021-06-22T17:22:54+02:00
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:3.0.0-M5:test (default-test) on project Selen
iumMavenProjekt1: No tests were executed! (Set -DfailIfNoTests=false to ignore this error.) -> [Help 1]
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.apache.maven.plugins:maven-surefire-plug
in:3.0.0-M5:test (default-test) on project SeleniumMavenProjekt1: No tests were executed! (Set -DfailIfNoTests=false to ig
nore this error.)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:215)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:156)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:148)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:117)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:81)
at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build (SingleThreadedBuilder.java:5
6)
at org.apache.maven.lifecycle.internal.LifecycleStarter.execute (LifecycleStarter.java:128)
at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:305)
at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:192)
at org.apache.maven.DefaultMaven.execute (DefaultMaven.java:105)
at org.apache.maven.cli.MavenCli.execute (MavenCli.java:957)
at org.apache.maven.cli.MavenCli.doMain (MavenCli.java:289)
at org.apache.maven.cli.MavenCli.main (MavenCli.java:193)
at jdk.internal.reflect.NativeMethodAccessorImpl.invoke0 (Native Method)
at jdk.internal.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.java:64)
at jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke (Method.java:564)
at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced (Launcher.java:282)
at org.codehaus.plexus.classworlds.launcher.Launcher.launch (Launcher.java:225)
at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode (Launcher.java:406)
at org.codehaus.plexus.classworlds.launcher.Launcher.main (Launcher.java:347)
Caused by: org.apache.maven.plugin.MojoFailureException: No tests were executed! (Set -DfailIfNoTests=false to ignore this
error.)
at org.apache.maven.plugin.surefire.AbstractSurefireMojo.execute (AbstractSurefireMojo.java:925)
at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo (DefaultBuildPluginManager.java:137)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:210)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:156)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:148)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:117)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:81)
at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build (SingleThreadedBuilder.java:5
6)
at org.apache.maven.lifecycle.internal.LifecycleStarter.execute (LifecycleStarter.java:128)
at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:305)
at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:192)
at org.apache.maven.DefaultMaven.execute (DefaultMaven.java:105)
at org.apache.maven.cli.MavenCli.execute (MavenCli.java:957)
at org.apache.maven.cli.MavenCli.doMain (MavenCli.java:289)
at org.apache.maven.cli.MavenCli.main (MavenCli.java:193)
at jdk.internal.reflect.NativeMethodAccessorImpl.invoke0 (Native Method)
at jdk.internal.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.java:64)
at jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke (Method.java:564)
at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced (Launcher.java:282)
at org.codehaus.plexus.classworlds.launcher.Launcher.launch (Launcher.java:225)
at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode (Launcher.java:406)
at org.codehaus.plexus.classworlds.launcher.Launcher.main (Launcher.java:347)
[ERROR]
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoFailureException
[/CODE]

[CODE lang="java" title="mvn Fehlermeldung"]Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:3.0.0-M5:test[/CODE]

KONFIGURATION:

POM.xml

[CODE lang="java" title="POM xml"]<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 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>de.condingsolo</groupId>
<artifactId>SeleniumMavenProjekt1</artifactId>
<version>0.0.1-SNAPSHOT</version>

<dependencies>
<!-- https://mvnrepository.com/artifact/org.seleniumhq.selenium/selenium-java -->
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-java</artifactId>
<version>3.141.59</version>
</dependency>

<!-- https://mvnrepository.com/artifact/org.junit.jupiter/junit-jupiter-api -->
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-api</artifactId>
<!-- <version>5.6.2</version> vorher aktiv -->
<!-- <version>5.6.0</version> -->
<version>5.4.0</version>
<scope>test</scope>
</dependency>

<!-- https://mvnrepository.com/artifact/org.junit.jupiter/junit-jupiter -->
<!-- Von youtube Tutorial: https://www.youtube.com/watch?v=K7k3YkerakM bei Minute 3:02 -->

<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter</artifactId>
<version>5.6.2</version>
<scope>test</scope>
</dependency>

<!-- Zusatz
Quelle:
https://www.petrikainulainen.net/programming/testing/junit-5-tutorial-running-unit-tests-with-maven/
War im Udemy Tutorial nicht dabei.
-->


<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-engine</artifactId>
<version>5.4.2</version>
<!-- <version>5.3.2</version> -->
<!-- <version>5.7.0</version> -->
<scope>test</scope>
</dependency>


<dependency>
<groupId>org.apache.cassandra</groupId>
<artifactId>cassandra-all</artifactId>
<version>0.8.1</version>

<exclusions>
<exclusion>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-log4j12</artifactId>
</exclusion>
<exclusion>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
</exclusion>
</exclusions>

</dependency>

<!--
<dependency>
<groupId>org.apache.maven.surefire</groupId>
<artifactId>surefire</artifactId>
<version>
<version>3.0.0-M5</version>
<type>pom</type>
</dependency>
-->


<!-- https://mvnrepository.com/artifact/org.apache.maven.plugins/maven-surefire-plugin -->
<!--
<dependency>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>3.0.0-M5</version>
</dependency>
-->

<!--
<dependency>
<groupId>org.junit.platform</groupId>
<artifactId>junit-platform-surefire-provider</artifactId>
<version>1.2.0-M1</version>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-engine</artifactId>
<version>5.2.0-M1</version>
</dependency>
-->

</dependencies>

<build>

<!-- To define the plugin version in your parent POM -->
<pluginManagement>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>3.0.0-M5</version>
<!-- <version>2.22.2</version> -->

<!--
<configuration>
<includes>
<include>**/Test*.java</include>
</includes>
</configuration>
-->

</plugin>
</plugins>
</pluginManagement>

<!-- To use the plugin goals in your POM or parent POM -->
<!--
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>3.0.0-M5</version>
</plugin>
</plugins>
-->

</build>

</project>[/CODE]

Java Version:

[CODE lang="java" title="openjdk Version"]openjdk version "1.8.0_41"
OpenJDK Runtime Environment (build 1.8.0_41-b04)
OpenJDK Client VM (build 25.40-b25, mixed mode)[/CODE]

Beispiel einer Testklasse:

[CODE lang="java" title="Beispiel einer Testklasse"]import static org.junit.jupiter.api.Assertions.*;

import org.junit.After;
import org.junit.Before;
import org.junit.Test;
// import org.junit.jupiter.api.BeforeEach;
// import org.junit.jupiter.Test;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.openqa.selenium.WebDriver;

public class TestAufrufBrowserFirefox {

WebDriver driver;

@Before
public void initTest() {
System.out.println("Initialisierung Webdriver -> Firefox.");
System.setProperty("webdriver.gecko.driver", "./drivers/geckodriver.exe");
driver = new FirefoxDriver();
driver.get("https://codingsolo.de");
}

@After
public void afterTest() {
System.out.println("Test abgeschlossen - Aufräumen.");
driver.close();
}

@Test
public void testTitle() {
System.out.println("Starte Test Verifikation Titel.");
String expect = "coding blog - Coding Solo | programmierblog | tutorials | Videos";
assertEquals(expect, driver.getTitle());
System.out.println("Titel: " + driver.getTitle());
}

}[/CODE]

Ich würde gerne Screenshots der "Java Build Path Konfiguration" für "Libraries" und "Order and Export" angeben, das geht wohl nicht.

Gibt es ein Problem bzgl. openjdk und Maven?

Reichen die Informationen aus, um damit etwas anfangen zu können?

Vielen Dank schon mal vorab!
 
Jetzt sehe ich gerade Dateianhänge sind doch möglich. Anbei also die drei Screenshots zum Projektaufbau und zur Projektstruktur.
 

Anhänge

  • EclipseProjektstruktur.jpg
    EclipseProjektstruktur.jpg
    38,3 KB · Aufrufe: 11
  • JavaBuildPath_Libraries.jpg
    JavaBuildPath_Libraries.jpg
    85,2 KB · Aufrufe: 9
  • JavaBuildPath_Order_and_Export.jpg
    JavaBuildPath_Order_and_Export.jpg
    96 KB · Aufrufe: 12
Momentan hast du Junit 4 Annotationen in den Tests, aber Junit 5 in Maven als Dependancy. Das kann nicht klappen

Das im Eclipse Build Path neben den Maven Dependancies noch Junit 4 & 5 drinsteht - das hat da auch nix zu suchen. Da sollten die Maven Dependencies reichen. Ich wundere mich eher, dass Maven überhaupt die Tests kompiliert und keine Compile Errors wirft.

Das solltest du mal aufräumen:
* Dich für JUnit 4 oder 5 entscheiden (Ich empfehle 5)
* Die JUnit Dependencies aus dem Eclipse Build baus raus und rein über Maven managen

Dann sollte das auch klappen
 
Danke für die Rückmeldung!

In "Java Build Path - Libraries" habe ich JUnit 4 entfernt. Es wird entsprechend auch nicht mehr in "Java Build Path - Order and Export" angezeigt. Nach den Änderungen habe ich einen Eclipse Neustart gemacht.

In der pom.xml kann ich keinen Eintrag zu JUnit 4 erkennen, die pom.xml blieb also unverändert..

Den Code habe ich angepasst ensprechend (https://www.arhohuttunen.com/junit-5-migration/). Nun also die Annotations umgeschrieben auf JUnit 5.

Hier ein Beispielcode einer Testklasse:

[CODE lang="java" title="Beipiel Code einer Testklasse"]import static org.junit.jupiter.api.Assertions.*;

import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
// import org.junit.jupiter.api.BeforeEach;
// import org.junit.jupiter.Test;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.openqa.selenium.WebDriver;

public class TestAufrufBrowserFirefox {

WebDriver driver;

@BeforeEach
public void initTest() {
System.out.println("Initialisierung Webdriver -> Firefox.");
System.setProperty("webdriver.gecko.driver", "./drivers/geckodriver.exe");
driver = new FirefoxDriver();
driver.get("https://codingsolo.de");
}

@AfterEach
public void afterTest() {
System.out.println("Test abgeschlossen - Aufräumen.");
driver.close();
}

@Test
public void testTitle() {
System.out.println("Starte Test Verifikation Titel.");
String expect = "coding blog - Coding Solo | programmierblog | tutorials | Videos";
assertEquals(expect, driver.getTitle());
System.out.println("Titel: " + driver.getTitle());
}

}[/CODE]

Das Verhalten hat sich beim Teststart via Kontextmenü nicht geändert. Es wird als Success angezeigt und weiterhin dabei kein Test ausgeführt.

Terminalanzeige bei Start via Kontextmenü:

[CODE lang="java" title="Maven Temrinalanzeige via Kontextmenü"][INFO] Scanning for projects...
[INFO]
[INFO] ----------------< de.condingsolo:SeleniumMavenProjekt1 >----------------
[INFO] Building SeleniumMavenProjekt1 0.0.1-SNAPSHOT
[INFO] --------------------------------[ jar ]---------------------------------
[INFO]
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ SeleniumMavenProjekt1 ---
[WARNING] Using platform encoding (Cp1252 actually) to copy filtered resources, i.e. build is platform dependent!
[INFO] Copying 0 resource
[INFO]
[INFO] --- maven-compiler-plugin:3.1:compile (default-compile) @ SeleniumMavenProjekt1 ---
[INFO] Nothing to compile - all classes are up to date
[INFO]
[INFO] --- maven-resources-plugin:2.6:testResources (default-testResources) @ SeleniumMavenProjekt1 ---
[WARNING] Using platform encoding (Cp1252 actually) to copy filtered resources, i.e. build is platform dependent!
[INFO] Copying 0 resource
[INFO]
[INFO] --- maven-compiler-plugin:3.1:testCompile (default-testCompile) @ SeleniumMavenProjekt1 ---
[INFO] Changes detected - recompiling the module!
[WARNING] File encoding has not been set, using platform encoding Cp1252, i.e. build is platform dependent!
[INFO] Compiling 3 source files to C:\4ma\software\Eclipse\eclipse_workspace\SeleniumMavenProjekt1\target\test-classes
[INFO]
[INFO] --- maven-surefire-plugin:3.0.0-M5:test (default-test) @ SeleniumMavenProjekt1 ---
[INFO]
[INFO] -------------------------------------------------------
[INFO] T E S T S
[INFO] -------------------------------------------------------
[INFO]
[INFO] Results:
[INFO]
[INFO] Tests run: 0, Failures: 0, Errors: 0, Skipped: 0
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 4.052 s
[INFO] Finished at: 2021-06-23T11:44:48+02:00
[INFO] ------------------------------------------------------------------------
[/CODE]

Bei Testausführung via Terminal in Eclipse kommt es zu folgenden Meldungen:

[CODE lang="java" title="Testdurchführung via Terminal"]C:\Ordner\software\Eclipse\eclipse_workspace\SeleniumMavenProjekt1>mvn test
[INFO] Scanning for projects...
[INFO]
[INFO] ----------------< de.condingsolo:SeleniumMavenProjekt1 >----------------
[INFO] Building SeleniumMavenProjekt1 0.0.1-SNAPSHOT
[INFO] --------------------------------[ jar ]---------------------------------
[INFO]
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ SeleniumMavenProjekt1 ---
[WARNING] Using platform encoding (Cp1252 actually) to copy filtered resources, i.e. build is platform dependent!
[INFO] Copying 0 resource
[INFO]
[INFO] --- maven-compiler-plugin:3.1:compile (default-compile) @ SeleniumMavenProjekt1 ---
[INFO] Nothing to compile - all classes are up to date
[INFO]
[INFO] --- maven-resources-plugin:2.6:testResources (default-testResources) @ SeleniumMavenProjekt1 ---
[WARNING] Using platform encoding (Cp1252 actually) to copy filtered resources, i.e. build is platform dependent!
[INFO] Copying 0 resource
[INFO]
[INFO] --- maven-compiler-plugin:3.1:testCompile (default-testCompile) @ SeleniumMavenProjekt1 ---
[INFO] Changes detected - recompiling the module!
[WARNING] File encoding has not been set, using platform encoding Cp1252, i.e. build is platform dependent!
[INFO] Compiling 3 source files to C:\Ordner\software\Eclipse\eclipse_workspace\SeleniumMavenProjekt1\target\test-classes
[INFO] -------------------------------------------------------------
[ERROR] COMPILATION ERROR :
[INFO] -------------------------------------------------------------
[ERROR] Source option 5 is no longer supported. Use 7 or later.
[ERROR] Target option 5 is no longer supported. Use 7 or later.
[INFO] 2 errors
[INFO] -------------------------------------------------------------
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 1.902 s
[INFO] Finished at: 2021-06-23T11:55:17+02:00
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.1:testCompile (default-testCompile) on project SeleniumMavenProjekt1: Compilation failu
re: Compilation failure:
[ERROR] Source option 5 is no longer supported. Use 7 or later.
[ERROR] Target option 5 is no longer supported. Use 7 or later.
[ERROR] -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoFailureException[/CODE]

Ich nehme es geht um diesen Teil:

[CODE lang="java" title="Maven Fehlermeldung"][ERROR] Source option 5 is no longer supported. Use 7 or later.
[ERROR] Target option 5 is no longer supported. Use 7 or later.
[INFO] 2 errors[/CODE]

bzw.

[CODE lang="java" title="Maven Compilation Error im Terminal"][ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.1:testCompile (default-testCompile) on project SeleniumMavenProjekt1: Compilation failu
re: Compilation failure:
[ERROR] Source option 5 is no longer supported. Use 7 or later.
[ERROR] Target option 5 is no longer supported. Use 7 or later.[/CODE]

Fehlen da Goal Angaben? Führe ich die falsch aus?
Reicht ...
[CODE lang="java" title="mvn Command"]mvn test[/CODE]
... nicht?

Ich weiß nicht welche Source Option 7 statt 5 gemeint ist ...

Danke und viele Grüße
 
Hier noch die aktuellen Java Build Path Screenshots für die Anzeigen der Libraries und Order and Export.
 

Anhänge

  • JavaBuildPath_Libraries_NEU.jpg
    JavaBuildPath_Libraries_NEU.jpg
    80,6 KB · Aufrufe: 4
  • JavaBuildPath_Order_and_Export_NEU.jpg
    JavaBuildPath_Order_and_Export_NEU.jpg
    91,5 KB · Aufrufe: 4
Füg mal in Deine pom.xml noch ein:
Code:
    <properties>
        <maven.compiler.source>1.8</maven.compiler.source>
        <maven.compiler.target>1.8</maven.compiler.target>
    </properties>
für Java 8 bzw.
Code:
    <properties>
        <maven.compiler.source>11</maven.compiler.source>
        <maven.compiler.target>11</maven.compiler.target>
    </properties>
für Java 11 und später (12,13,14,15,16).
 
Danke! Es funktioniert aber leider immer noch nicht. Der Test läuft als Success durch ohne weiterhin die Tests anzusprechen oder zu bemerken.

Java Version:

[CODE lang="java" title="openjdk Version wegen POM"]openjdk version "1.8.0_41"
OpenJDK Runtime Environment (build 1.8.0_41-b04)
OpenJDK Client VM (build 25.40-b25, mixed mode)[/CODE]

Gewählten POM.xml Eintrag für die Properties:

[CODE lang="java" title="POM Properties maven Compiler"]<properties>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
</properties>[/CODE]

Hier nochmal die vollständige POM.xml:

[CODE lang="java" title="Vollständige POM xml wegen Properties"]<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 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>de.condingsolo</groupId>
<artifactId>SeleniumMavenProjekt1</artifactId>
<version>0.0.1-SNAPSHOT</version>


<properties>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
</properties>

<dependencies>
<!-- https://mvnrepository.com/artifact/org.seleniumhq.selenium/selenium-java -->
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-java</artifactId>
<version>3.141.59</version>
</dependency>

<!-- https://mvnrepository.com/artifact/org.junit.jupiter/junit-jupiter-api -->
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-api</artifactId>
<!-- <version>5.6.2</version> vorher aktiv -->
<!-- <version>5.6.0</version> -->
<version>5.4.0</version>
<scope>test</scope>
</dependency>

<!-- https://mvnrepository.com/artifact/org.junit.jupiter/junit-jupiter -->
<!-- Von youtube Tutorial: https://www.youtube.com/watch?v=K7k3YkerakM bei Minute 3:02 -->

<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter</artifactId>
<version>5.6.2</version>
<scope>test</scope>
</dependency>

<!-- Zusatz
Quelle:
https://www.petrikainulainen.net/programming/testing/junit-5-tutorial-running-unit-tests-with-maven/
War im Udemy Tutorial nicht dabei.
-->


<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-engine</artifactId>
<version>5.4.2</version>
<!-- <version>5.3.2</version> -->
<!-- <version>5.7.0</version> -->
<scope>test</scope>
</dependency>


<dependency>
<groupId>org.apache.cassandra</groupId>
<artifactId>cassandra-all</artifactId>
<version>0.8.1</version>

<exclusions>
<exclusion>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-log4j12</artifactId>
</exclusion>
<exclusion>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
</exclusion>
</exclusions>

</dependency>

<!--
<dependency>
<groupId>org.apache.maven.surefire</groupId>
<artifactId>surefire</artifactId>
<version>
<version>3.0.0-M5</version>
<type>pom</type>
</dependency>
-->


<!-- https://mvnrepository.com/artifact/org.apache.maven.plugins/maven-surefire-plugin -->
<!--
<dependency>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>3.0.0-M5</version>
</dependency>
-->

<!--
<dependency>
<groupId>org.junit.platform</groupId>
<artifactId>junit-platform-surefire-provider</artifactId>
<version>1.2.0-M1</version>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-engine</artifactId>
<version>5.2.0-M1</version>
</dependency>
-->

</dependencies>

<build>

<!-- To define the plugin version in your parent POM -->
<pluginManagement>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>3.0.0-M5</version>
<!-- <version>2.22.2</version> -->

<!--
<configuration>
<includes>
<include>**/Test*.java</include>
</includes>
</configuration>
-->

</plugin>
</plugins>
</pluginManagement>

<!-- To use the plugin goals in your POM or parent POM -->
<!--
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>3.0.0-M5</version>
</plugin>
</plugins>
-->

</build>

</project>[/CODE]

Egal, ob Teststart via Kontextmenü oder Terminaleingabe, die Meldung ist die gleiche:

Durchlauf mit Successmeldung, erst mit "clean", dann mit "test":

[CODE lang="java" title="Maven clean test Durchlauf"]C:\ordner\software\Eclipse\eclipse_workspace\SeleniumMavenProjekt1>mvn clean
[INFO] Scanning for projects...
[INFO]
[INFO] ----------------< de.condingsolo:SeleniumMavenProjekt1 >----------------
[INFO] Building SeleniumMavenProjekt1 0.0.1-SNAPSHOT
[INFO] --------------------------------[ jar ]---------------------------------
[INFO]
[INFO] --- maven-clean-plugin:2.5:clean (default-clean) @ SeleniumMavenProjekt1 ---
[INFO] Deleting C:\ordner\software\Eclipse\eclipse_workspace\SeleniumMavenProjekt1\target
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 0.314 s
[INFO] Finished at: 2021-06-23T13:28:26+02:00
[INFO] ------------------------------------------------------------------------

C:\ordner\software\Eclipse\eclipse_workspace\SeleniumMavenProjekt1>mvn test
[INFO] Scanning for projects...
[INFO]
[INFO] ----------------< de.condingsolo:SeleniumMavenProjekt1 >----------------
[INFO] Building SeleniumMavenProjekt1 0.0.1-SNAPSHOT
[INFO] --------------------------------[ jar ]---------------------------------
[INFO]
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ SeleniumMavenProjekt1 ---
[WARNING] Using platform encoding (Cp1252 actually) to copy filtered resources, i.e. build is platform dependent!
[INFO] Copying 0 resource
[INFO]
[INFO] --- maven-compiler-plugin:3.1:compile (default-compile) @ SeleniumMavenProjekt1 ---
[INFO] Nothing to compile - all classes are up to date
[INFO]
[INFO] --- maven-resources-plugin:2.6:testResources (default-testResources) @ SeleniumMavenProjekt1 ---
[WARNING] Using platform encoding (Cp1252 actually) to copy filtered resources, i.e. build is platform dependent!
[INFO] Copying 0 resource
[INFO]
[INFO] --- maven-compiler-plugin:3.1:testCompile (default-testCompile) @ SeleniumMavenProjekt1 ---
[INFO] Changes detected - recompiling the module!
[WARNING] File encoding has not been set, using platform encoding Cp1252, i.e. build is platform dependent!
[INFO] Compiling 3 source files to C:\ordner\software\Eclipse\eclipse_workspace\SeleniumMavenProjekt1\target\test-classes
[INFO]
[INFO] --- maven-surefire-plugin:3.0.0-M5:test (default-test) @ SeleniumMavenProjekt1 ---
[INFO]
[INFO] -------------------------------------------------------
[INFO] T E S T S
[INFO] -------------------------------------------------------
[INFO]
[INFO] Results:
[INFO]
[INFO] Tests run: 0, Failures: 0, Errors: 0, Skipped: 0
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 4.279 s
[INFO] Finished at: 2021-06-23T13:28:36+02:00
[INFO] ------------------------------------------------------------------------[/CODE]

Warum werden die Tests nicht angesprochen?
Die Klassen beginnen mit "Test ...", liegen im richtigen Ordner ...

Ich verstehe das nicht, was könnte das noch sein?
 
Mit der pom funktionierts, das ist deine von oben, ergänzt um source und taget, und alles überflüssige ist rausgeschmissen:

XML:
<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 https://maven.apache.org/xsd/maven-4.0.0.xsd">

  <modelVersion>4.0.0</modelVersion>

  <groupId>de.condingsolo</groupId>
  <artifactId>SeleniumMavenProjekt1</artifactId>
  <version>0.0.1-SNAPSHOT</version>

<properties>
  <maven.compiler.source>1.8</maven.compiler.source>
  <maven.compiler.target>1.8</maven.compiler.target>
</properties>

  <dependencies>

    <dependency>
        <groupId>org.seleniumhq.selenium</groupId>
        <artifactId>selenium-java</artifactId>
        <version>3.141.59</version>
    </dependency>

    <dependency>
        <groupId>org.junit.jupiter</groupId>
        <artifactId>junit-jupiter</artifactId>
        <version>5.6.2</version>
        <scope>test</scope>
    </dependency>

   <dependency>
        <groupId>org.apache.cassandra</groupId>
        <artifactId>cassandra-all</artifactId>
        <version>0.8.1</version>
        <exclusions>
              <exclusion>
                <groupId>org.slf4j</groupId>
                <artifactId>slf4j-log4j12</artifactId>
              </exclusion>
              <exclusion>
                <groupId>log4j</groupId>
                <artifactId>log4j</artifactId>
             </exclusion>
        </exclusions>
  </dependency>

</dependencies>


  <build>

    <pluginManagement>
      <plugins>
        <plugin>
          <groupId>org.apache.maven.plugins</groupId>
          <artifactId>maven-surefire-plugin</artifactId>
          <version>3.0.0-M5</version>
        </plugin>
      </plugins>
    </pluginManagement>

  </build>

</project>


Zig Dependencies waren da doppelt in unterschiedlichen Versionen, vermutlich war das das Problem.
 
Danke für das Aufräumen der pom.xml! Ich suche schon wirklich lange nach einer Lösung und habe entsprechend viel rumprobiert (wie man der pom ansah). Letztendlich wusste ich auch nicht mehr was richtig und falsch oder überflüssig ist.

Aber ... es funktioniert auch mit der aufgeräumten pom.xml nicht:
[CODE lang="java" title="Keine Testfälle angesprochen"][INFO] Tests run: 0, Failures: 0, Errors: 0, Skipped: 0[/CODE]

Was das "bekannte Problem" angeht so kenne ich den Beitrag zum erwähnten Link von stackoverflow und hab entsprechend was versucht (wie man sieht ohne Ergebnis) und bin nun bei dem dort verlinkten Beitrag (https://springframework.guru/why-your-junit-5-tests-are-not-running-under-maven/) zum Thema der Maven Version.

Es wird empfohlen auf Maven 3.6.0 umzustellen. Das ist ein Beitrag von 2018 und ich nutze eine höhere Maven Version (3.8.1):

[CODE lang="java" title="Maven Version"]C:\ordner\software\Eclipse\eclipse_workspace\SeleniumMavenProjekt1>mvn -v
Apache Maven 3.8.1 (05c21c65bdfed0f71a2f2ada8b84da59348c4c5d)
Maven home: C:\Program Files\Java\apache-maven-3.8.1\bin\..
Java version: 15.0.2, vendor: Oracle Corporation, runtime: C:\ordner\software\Eclipse\eclipse\plugins\org.eclipse.justj.openjdk.hotspot.jre.full.win32.x86_64_15.0.2.v2021
0201-0955\jre
Default locale: de_DE, platform encoding: Cp1252
OS name: "windows 10", version: "10.0", arch: "amd64", family: "windows"[/CODE]

Jetzt wüsste ich nicht wie ich ein Degrade durchführe bzw. ob das überhaupt sinnvoll ist?!

Es ist verrückt, ich komme nicht drauf.
 
Kannst du dein Projekt zippen und hochladen?

Bei mir läuft es unter den gleichen Bedingungen:
- aufgeräumte pom
- "TestSomething" im Default-Package
- Java 8 und 11
- Maven 3.8.1
 
Ahh, du hast immer noch Junit 4-Annotationen:

Den Code habe ich angepasst ensprechend (https://www.arhohuttunen.com/junit-5-migration/). Nun also die Annotations umgeschrieben auf JUnit 5.

Hier ein Beispielcode einer Testklasse:

[CODE lang="java" title="Beipiel Code einer Testklasse"]import static org.junit.jupiter.api.Assertions.*;

import org.junit.After;
import org.junit.Before;
import org.junit.Test; <-######
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
// import org.junit.jupiter.api.BeforeEach;
// import org.junit.jupiter.Test;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.openqa.selenium.WebDriver;

....
[/code]



Das Maven da keinen Fehler wirft, liegt btw an org.apache.thrift:libthrift (durch org.apache.cassandra:cassandra-all), was junit 4 als normale Dependance rein zieht.
 
Aaaah! Groooßartig! DANKE!

[CODE lang="java" title="Testdurchlauf"][INFO] Tests run: 3, Failures: 0, Errors: 0, Skipped: 0[/CODE]

Ich habe die Imports geändert, fiel aber da auf die automatischen Imports via Mouseover am Code rein. Eclipse zog immer die JUnit 4 Imports (import org.junit.Test😉 und nicht JUnit 5 (import org.junit.jupiter.api.Test😉. Das war knapp🙂

OK, damit ist dieses Problem endlich gelöst!

Großen Dank nochmal!
 

Neue Themen


Zurück
Oben