Re: Tests not running on Maven
It Worked!! New version of pom.xml $ cat pom.xml 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;> 4.0.0 br.edu.ifrs totalinventory 1.0-SNAPSHOT war totalinventory Maven Webapp http://www.poa.ifrs.edu.br UTF-8 1.7 1.7 junit junit 4.11 test org.junit.jupiter junit-jupiter-engine 5.4.0 test javax.persistence javax.persistence-api 2.2 javax.ejb ejb-api 3.0 provided javax.ws.rs javax.ws.rs-api 2.1.1 javax.annotation javax.annotation-api 1.3.2 org.apache.maven.surefire surefire-junit47 2.22.1 totalinventory maven-clean-plugin 3.1.0 maven-resources-plugin 3.0.2 maven-compiler-plugin 3.8.0 maven-surefire-plugin 2.22.1 org.apache.maven.plugins maven-failsafe-plugin 2.22.1 maven-war-plugin 3.2.2 maven-install-plugin 2.5.2 maven-deploy-plugin 2.8.2 Result of mvn test: $ mvn clean test [INFO] Scanning for projects... [INFO] [INFO] -< br.edu.ifrs:totalinventory >- [INFO] Building totalinventory Maven Webapp 1.0-SNAPSHOT [INFO] [ war ]- [INFO] [INFO] --- maven-clean-plugin:3.1.0:clean (default-clean) @ totalinventory --- [INFO] Deleting /home/jeronimo/Documents/maven-testes/totalinventory/target [INFO] [INFO] --- maven-resources-plugin:3.0.2:resources (default-resources) @ totalinventory --- [INFO] Using 'UTF-8' encoding to copy filtered resources. [INFO] Copying 0 resource [INFO] [INFO] --- maven-compiler-plugin:3.8.0:compile (default-compile) @ totalinventory --- [INFO] Changes detected - recompiling the module! [INFO] Compiling 5 source files to /home/jeronimo/Documents/maven-testes/totalinventory/target/classes [INFO] [INFO] --- maven-resources-plugin:3.0.2:testResources (default-testResources) @ totalinventory --- [INFO] Using 'UTF-8' encoding to copy filtered resources. [INFO] skip non existing resourceDirectory /home/jeronimo/Documents/maven-testes/totalinventory/src/test/resources [INFO] [INFO] --- maven-compiler-plugin:3.8.0:testCompile (default-testCompile) @ totalinventory --- [INFO] Changes detected - recompiling the module! [INFO] Compiling 1 source file to /home/jeronimo/Documents/maven-testes/totalinventory/target/test-classes [INFO] [INFO] --- maven-surefire-plugin:2.22.1:test (default-test) @ totalinventory --- [INFO] [INFO] --- [INFO] T E S T S [INFO] --- [INFO] Running br.edu.ifrs.test.FabricanteTest [INFO] Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.009 s - in br.edu.ifrs.test.FabricanteTest [INFO] [INFO] Results: [INFO] [INFO] Tests run: 1, Failures: 0, Errors: 0, Skipped: 0 [INFO] [INFO] [INFO] BUILD SUCCESS [INFO] [INFO] Total time: 2.707 s [INFO] Finished at: 2019-12-09T12:19:59-02:00 [INFO] Thanks guys! Jeronimo Em seg., 9 de dez. de 2019 às 11:11, Tibor Digana escreveu: > Hi Jeronimo, > > The old version of Surefire and Failsafe required to have the Junit5 > engine in the test dependency. > > But you do not have to declare it if you use the version 3.0.0-M4. > It's enough to have only Junit Jupiter API in the test dependency. > The plugin will find out the engine from Junit5. > > btw, pls remove the dependency with the artifactId: surefire-junit47. > > As Karl has explained, see the documentation in [1]. This should help. > > If you have any problem, feel free to reply. > > Cheers > Tibor17 > > On Mon, Dec 9, 2019 at 2:12 PM Karl Heinz Marbaise > wrote: > >> Hi, >> >> first you have to use junit-jupiter-engine[1] instead of api apart from >> that you won't be able to get that running cause JUnit Jupiter requires >> JDK8+ (see [2]). >> >> furthermore dependencies to junit provider is simply not needed cause >> this is automatically done by maven-surefire/maven-failsafe-plugin... >> >> Kind regards >> Karl Heinz Marbaise >> >> [1]: >> >> http://maven.apache.org/surefire/maven-surefire-plugin/examples/junit-platform.html >> [2]: >> https://junit.org/junit5/docs/current/user-guide/#overview-java-versions >>
Re: Tests not running on Maven
Hi Jeronimo, The old version of Surefire and Failsafe required to have the Junit5 engine in the test dependency. But you do not have to declare it if you use the version 3.0.0-M4. It's enough to have only Junit Jupiter API in the test dependency. The plugin will find out the engine from Junit5. btw, pls remove the dependency with the artifactId: surefire-junit47. As Karl has explained, see the documentation in [1]. This should help. If you have any problem, feel free to reply. Cheers Tibor17 On Mon, Dec 9, 2019 at 2:12 PM Karl Heinz Marbaise wrote: > Hi, > > first you have to use junit-jupiter-engine[1] instead of api apart from > that you won't be able to get that running cause JUnit Jupiter requires > JDK8+ (see [2]). > > furthermore dependencies to junit provider is simply not needed cause > this is automatically done by maven-surefire/maven-failsafe-plugin... > > Kind regards > Karl Heinz Marbaise > > [1]: > > http://maven.apache.org/surefire/maven-surefire-plugin/examples/junit-platform.html > [2]: > https://junit.org/junit5/docs/current/user-guide/#overview-java-versions > > On 09.12.19 13:31, Jeronimo wrote: > > Hi, > > > > I am using Maven 3.6 > > > > $ mvn -version > > Apache Maven 3.6.0 > > Maven home: /usr/share/maven > > Java version: 11.0.4, vendor: Ubuntu, runtime: > > /usr/lib/jvm/java-11-openjdk-amd64 > > Default locale: en_US, platform encoding: UTF-8 > > OS name: "linux", version: "5.0.0-37-generic", arch: "amd64", family: > "unix" > > > > My pom.xml seems like this: > > $ cat pom.xml > > > > > > 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;> > >4.0.0 > > > >br.edu.ifrs > >totalinventory > >1.0-SNAPSHOT > >war > > > >totalinventory Maven Webapp > >http://www.poa.ifrs.edu.br > > > > > > UTF-8 > > 1.7 > > 1.7 > > > > > > > > > >junit > >junit > >4.11 > >test > > > > > >org.junit.jupiter > >junit-jupiter-api > >5.5.2 > >test > > > > > > javax.persistence > > javax.persistence-api > > 2.2 > > > > > > javax.ejb > > ejb-api > > 3.0 > > provided > > > > > > javax.ws.rs > > javax.ws.rs-api > > 2.1.1 > > > > > > javax.annotation > > javax.annotation-api > > 1.3.2 > > > > > >org.apache.maven.surefire > >surefire-junit47 > >2.22.1 > > > > > > > > > > totalinventory > > > > > > > >maven-clean-plugin > >3.1.0 > > > > > > > >maven-resources-plugin > >3.0.2 > > > > > >maven-compiler-plugin > >3.8.0 > > > > > >maven-surefire-plugin > >2.22.1 > > > > > >org.apache.maven.plugins > >maven-failsafe-plugin > >2.22.1 > > > > > >maven-war-plugin > >3.2.2 > > > > > >maven-install-plugin > >2.5.2 > > > > > >maven-deploy-plugin > >2.8.2 > > > > > > > > > > > > > > > > When trying to execute JUnit testes: > > $ mvn clean test > > [INFO] Scanning for projects... > > [INFO] > > [INFO] -< br.edu.ifrs:totalinventory > >> - > > [INFO] Building totalinventory Maven Webapp 1.0-SNAPSHOT > > [INFO] [ war > > ]- > > [INFO] > > [INFO] --- maven-clean-plugin:3.1.0:clean (default-clean) @ > totalinventory > > --- > > [INFO] Deleting > /home/jeronimo/Documents/maven-testes/totalinventory/target > > [INFO] > > [INFO] --- maven-resources-plugin:3.0.2:resources (default-resources) @ > > totalinventory --- > > [INFO] Using 'UTF-8' encoding to copy filtered resources. > > [INFO] Copying 1 resource > > [INFO] > > [INFO] --- maven-compiler-plugin:3.8.0:compile (default-compile) @ > > totalinventory --- > > [INFO] Changes detected - recompiling the module! > > [INFO] Compiling 5 source files to > > /home/jeronimo/Documents/maven-testes/totalinventory/target/classes > > [INFO] > > [INFO] --- maven-resources-plugin:3.0.2:testResources > > (default-testResources) @ totalinventory --- > > [INFO] Using 'UTF-8' encoding to copy filtered resources. > > [INFO] skip non existing resourceDirectory > > /home/jeronimo/Documents/maven-testes/totalinventory/src/test/resources > > [INFO] > > [INFO] --- maven-compiler-plugin:3.8.0:testCompile (default-testCompile) > @ > > totalinventory --- > > [INFO] Changes detected - recompiling the module! > > [INFO] *Compiling 1 source
Re: Tests not running on Maven
Hi, first you have to use junit-jupiter-engine[1] instead of api apart from that you won't be able to get that running cause JUnit Jupiter requires JDK8+ (see [2]). furthermore dependencies to junit provider is simply not needed cause this is automatically done by maven-surefire/maven-failsafe-plugin... Kind regards Karl Heinz Marbaise [1]: http://maven.apache.org/surefire/maven-surefire-plugin/examples/junit-platform.html [2]: https://junit.org/junit5/docs/current/user-guide/#overview-java-versions On 09.12.19 13:31, Jeronimo wrote: Hi, I am using Maven 3.6 $ mvn -version Apache Maven 3.6.0 Maven home: /usr/share/maven Java version: 11.0.4, vendor: Ubuntu, runtime: /usr/lib/jvm/java-11-openjdk-amd64 Default locale: en_US, platform encoding: UTF-8 OS name: "linux", version: "5.0.0-37-generic", arch: "amd64", family: "unix" My pom.xml seems like this: $ cat pom.xml 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;> 4.0.0 br.edu.ifrs totalinventory 1.0-SNAPSHOT war totalinventory Maven Webapp http://www.poa.ifrs.edu.br UTF-8 1.7 1.7 junit junit 4.11 test org.junit.jupiter junit-jupiter-api 5.5.2 test javax.persistence javax.persistence-api 2.2 javax.ejb ejb-api 3.0 provided javax.ws.rs javax.ws.rs-api 2.1.1 javax.annotation javax.annotation-api 1.3.2 org.apache.maven.surefire surefire-junit47 2.22.1 totalinventory maven-clean-plugin 3.1.0 maven-resources-plugin 3.0.2 maven-compiler-plugin 3.8.0 maven-surefire-plugin 2.22.1 org.apache.maven.plugins maven-failsafe-plugin 2.22.1 maven-war-plugin 3.2.2 maven-install-plugin 2.5.2 maven-deploy-plugin 2.8.2 When trying to execute JUnit testes: $ mvn clean test [INFO] Scanning for projects... [INFO] [INFO] -< br.edu.ifrs:totalinventory - [INFO] Building totalinventory Maven Webapp 1.0-SNAPSHOT [INFO] [ war ]- [INFO] [INFO] --- maven-clean-plugin:3.1.0:clean (default-clean) @ totalinventory --- [INFO] Deleting /home/jeronimo/Documents/maven-testes/totalinventory/target [INFO] [INFO] --- maven-resources-plugin:3.0.2:resources (default-resources) @ totalinventory --- [INFO] Using 'UTF-8' encoding to copy filtered resources. [INFO] Copying 1 resource [INFO] [INFO] --- maven-compiler-plugin:3.8.0:compile (default-compile) @ totalinventory --- [INFO] Changes detected - recompiling the module! [INFO] Compiling 5 source files to /home/jeronimo/Documents/maven-testes/totalinventory/target/classes [INFO] [INFO] --- maven-resources-plugin:3.0.2:testResources (default-testResources) @ totalinventory --- [INFO] Using 'UTF-8' encoding to copy filtered resources. [INFO] skip non existing resourceDirectory /home/jeronimo/Documents/maven-testes/totalinventory/src/test/resources [INFO] [INFO] --- maven-compiler-plugin:3.8.0:testCompile (default-testCompile) @ totalinventory --- [INFO] Changes detected - recompiling the module! [INFO] *Compiling 1 source file *to /home/jeronimo/Documents/maven-testes/totalinventory/target/test-classes [INFO] [INFO] --- maven-surefire-plugin:2.22.1:test (default-test) @ totalinventory --- [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: 2.525 s [INFO] Finished at: 2019-12-09T10:24:37-02:00 [INFO] The phases seems to compile one test class but don't run any. My Test class is on ./src/test/java $ cat src/test/java/FabricanteTest.java package br.edu.ifrs.test; import static org.junit.jupiter.api.Assertions.assertEquals; import br.edu.ifrs.model.Fabricante; import org.junit.jupiter.api.Test; public class FabricanteTest { @Test public void testGetName() { Fabricante fabricante = new Fabricante("Dell", "www.dell.com");
Tests not running on Maven
Hi, I am using Maven 3.6 $ mvn -version Apache Maven 3.6.0 Maven home: /usr/share/maven Java version: 11.0.4, vendor: Ubuntu, runtime: /usr/lib/jvm/java-11-openjdk-amd64 Default locale: en_US, platform encoding: UTF-8 OS name: "linux", version: "5.0.0-37-generic", arch: "amd64", family: "unix" My pom.xml seems like this: $ cat pom.xml 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;> 4.0.0 br.edu.ifrs totalinventory 1.0-SNAPSHOT war totalinventory Maven Webapp http://www.poa.ifrs.edu.br UTF-8 1.7 1.7 junit junit 4.11 test org.junit.jupiter junit-jupiter-api 5.5.2 test javax.persistence javax.persistence-api 2.2 javax.ejb ejb-api 3.0 provided javax.ws.rs javax.ws.rs-api 2.1.1 javax.annotation javax.annotation-api 1.3.2 org.apache.maven.surefire surefire-junit47 2.22.1 totalinventory maven-clean-plugin 3.1.0 maven-resources-plugin 3.0.2 maven-compiler-plugin 3.8.0 maven-surefire-plugin 2.22.1 org.apache.maven.plugins maven-failsafe-plugin 2.22.1 maven-war-plugin 3.2.2 maven-install-plugin 2.5.2 maven-deploy-plugin 2.8.2 When trying to execute JUnit testes: $ mvn clean test [INFO] Scanning for projects... [INFO] [INFO] -< br.edu.ifrs:totalinventory >- [INFO] Building totalinventory Maven Webapp 1.0-SNAPSHOT [INFO] [ war ]- [INFO] [INFO] --- maven-clean-plugin:3.1.0:clean (default-clean) @ totalinventory --- [INFO] Deleting /home/jeronimo/Documents/maven-testes/totalinventory/target [INFO] [INFO] --- maven-resources-plugin:3.0.2:resources (default-resources) @ totalinventory --- [INFO] Using 'UTF-8' encoding to copy filtered resources. [INFO] Copying 1 resource [INFO] [INFO] --- maven-compiler-plugin:3.8.0:compile (default-compile) @ totalinventory --- [INFO] Changes detected - recompiling the module! [INFO] Compiling 5 source files to /home/jeronimo/Documents/maven-testes/totalinventory/target/classes [INFO] [INFO] --- maven-resources-plugin:3.0.2:testResources (default-testResources) @ totalinventory --- [INFO] Using 'UTF-8' encoding to copy filtered resources. [INFO] skip non existing resourceDirectory /home/jeronimo/Documents/maven-testes/totalinventory/src/test/resources [INFO] [INFO] --- maven-compiler-plugin:3.8.0:testCompile (default-testCompile) @ totalinventory --- [INFO] Changes detected - recompiling the module! [INFO] *Compiling 1 source file *to /home/jeronimo/Documents/maven-testes/totalinventory/target/test-classes [INFO] [INFO] --- maven-surefire-plugin:2.22.1:test (default-test) @ totalinventory --- [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: 2.525 s [INFO] Finished at: 2019-12-09T10:24:37-02:00 [INFO] The phases seems to compile one test class but don't run any. My Test class is on ./src/test/java $ cat src/test/java/FabricanteTest.java package br.edu.ifrs.test; import static org.junit.jupiter.api.Assertions.assertEquals; import br.edu.ifrs.model.Fabricante; import org.junit.jupiter.api.Test; public class FabricanteTest { @Test public void testGetName() { Fabricante fabricante = new Fabricante("Dell", "www.dell.com"); assertEquals("Dell", fabricante.getName()); } } I have no idea the cause of not running tests. Any help? Regard's Jeronimo
Checking if tests are running under maven
Is there any way at runtime for a test to know if it is running under maven (as opposed to having been invoked in the IDE)? Why? Some of the developers on my team comment out tests during development to only run a sub-set (as Eclipse doesn't seem to let you just run a single test easily any other way) I'd like to have some facility that ensures all the tests always get run when the official maven testing is happening, regardless of what the developer's been up to. thanks James For more information about Barclays Capital, please visit our web site at http://www.barcap.com. Internet communications are not secure and therefore the Barclays Group does not accept legal responsibility for the contents of this message. Although the Barclays Group operates anti-virus programmes, it does not accept responsibility for any damage whatsoever that is caused by viruses being passed. Any views or opinions presented are solely those of the author and do not necessarily represent those of the Barclays Group. Replies to this email may be monitored by the Barclays Group for operational or business reasons. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Checking if tests are running under maven
[EMAIL PROTECTED] wrote on Wednesday, September 22, 2004 11:46 AM: Is there any way at runtime for a test to know if it is running under maven (as opposed to having been invoked in the IDE)? Why? Some of the developers on my team comment out tests during development to only run a sub-set (as Eclipse doesn't seem to let you just run a single test easily any other way) At least Eclipse 3.0: Right click on the test class in the package view and execute. You can even run a single fixture by selecting it in the JUnit/hierarchy. And with a JUnit run target you can also select packages or single classes. I'd like to have some facility that ensures all the tests always get run when the official maven testing is happening, regardless of what the developer's been up to. If they're commented out you or Maven can't do a lot ;-) - Jörg - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Checking if tests are running under maven
[EMAIL PROTECTED] wrote: Why? Some of the developers on my team comment out tests during development to only run a sub-set (as Eclipse doesn't seem to let you just run a single test easily any other way) Right click on the test, select run, select run JUnit-test If you wish to run all tests in a package, right click on the package and select the previous run-run Junit test. If you wish to re-run the test, simply click on the run button in the java perspective (or the debug button). To select a previous launched test-set, select the 'arrow' down next to the run button on the toolbar, and select the testset. Hope to help, Martijn - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Checking if tests are running under maven
I think this only applies to Eclipse 3.0? We're on 2.1 still as the clearcase support in 3.0 is currently pretty terrible James -Original Message- From: Martijn Dashorst [mailto:[EMAIL PROTECTED] Sent: 22 September 2004 10:57 To: Maven Users List Subject: Re: Checking if tests are running under maven [EMAIL PROTECTED] wrote: Why? Some of the developers on my team comment out tests during development to only run a sub-set (as Eclipse doesn't seem to let you just run a single test easily any other way) Right click on the test, select run, select run JUnit-test If you wish to run all tests in a package, right click on the package and select the previous run-run Junit test. If you wish to re-run the test, simply click on the run button in the java perspective (or the debug button). To select a previous launched test-set, select the 'arrow' down next to the run button on the toolbar, and select the testset. Hope to help, Martijn - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] For more information about Barclays Capital, please visit our web site at http://www.barcap.com. Internet communications are not secure and therefore the Barclays Group does not accept legal responsibility for the contents of this message. Although the Barclays Group operates anti-virus programmes, it does not accept responsibility for any damage whatsoever that is caused by viruses being passed. Any views or opinions presented are solely those of the author and do not necessarily represent those of the Barclays Group. Replies to this email may be monitored by the Barclays Group for operational or business reasons. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Checking if tests are running under maven
[EMAIL PROTECTED] wrote: I think this only applies to Eclipse 3.0? We're on 2.1 still as the clearcase support in 3.0 is currently pretty terrible Ok, if you're stuck on 2.1 then perhaps you could define TestSuites (one for each developer): public class Developer1Suite() extends TestCase { public static Test suite() { TestSuite suite = new TestSuite(); suite.addTestSuite(MyFooTest.class); suite.addTestSuite(MyBarTest.class); return suite; } } This way, you can exclude the developer suites easily with an ant pattern, and the developers can run their own tests easy. Hope this helps until eclipse 3.0 :-) Martijn - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Checking if tests are running under maven
Nice idea - seems to do what I need - thanks James -Original Message- From: Martijn Dashorst [mailto:[EMAIL PROTECTED] Sent: 22 September 2004 11:51 To: Maven Users List Subject: Re: Checking if tests are running under maven [EMAIL PROTECTED] wrote: I think this only applies to Eclipse 3.0? We're on 2.1 still as the clearcase support in 3.0 is currently pretty terrible Ok, if you're stuck on 2.1 then perhaps you could define TestSuites (one for each developer): public class Developer1Suite() extends TestCase { public static Test suite() { TestSuite suite = new TestSuite(); suite.addTestSuite(MyFooTest.class); suite.addTestSuite(MyBarTest.class); return suite; } } This way, you can exclude the developer suites easily with an ant pattern, and the developers can run their own tests easy. Hope this helps until eclipse 3.0 :-) Martijn - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] For more information about Barclays Capital, please visit our web site at http://www.barcap.com. Internet communications are not secure and therefore the Barclays Group does not accept legal responsibility for the contents of this message. Although the Barclays Group operates anti-virus programmes, it does not accept responsibility for any damage whatsoever that is caused by viruses being passed. Any views or opinions presented are solely those of the author and do not necessarily represent those of the Barclays Group. Replies to this email may be monitored by the Barclays Group for operational or business reasons. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]