Re: Surefire - Forking - Identifying Tests that run in a particular fork
Hi Martin, OOTB you'll probably have to resort to -X (which logs way too much) and even then I am not 100% sure you'll get what you need. Did you have a look at |${surefire.forkNumber}| (see https://maven.apache.org/surefire/maven-surefire-plugin/examples/fork-options-and-parallel-execution.html)? I've been using this as a system property in my projects to: - write one logfile per fork (e.g. via Logback) - prefix each logged line with the fork number (also via Logback, especially useful for Jenins console log) - log each test method in a JUnit4 listener together with the log file (certainly also possible with JUnit5 etc.) - separate working directories, generate tracing ids etc. I can really recommend to take these extra measures, otherwise analyzing test failures with multiple forks and/or parallel modules (-T) will be a real pain in the long run. Cheers, Falko Am 02.07.2020 um 00:12 schrieb Martin Lambert: Hello, I'm currently using the Surefire plugin with Maven 3.6.3 and would like to know if there is any way to identify what tests were run in a given fork? I haven't seen any option for it in the current documentation. I'm running around ~10K test cases hence using the fork option to speed things up. The problem I'm trying to solve is that a single test intermittently fails, which, when run individually succeeds; I suspect this is due to a prior test case not cleaning up properly and would therefore like to be able to identify at a minimum what test cases are in a fork group so that I can take a divide and conquer approach to resolving the issue, even better would be to know which test cases ran before the failing test case. Thanks for your help, Martin.
Surefire - Forking - Identifying Tests that run in a particular fork
Hello, I'm currently using the Surefire plugin with Maven 3.6.3 and would like to know if there is any way to identify what tests were run in a given fork? I haven't seen any option for it in the current documentation. I'm running around ~10K test cases hence using the fork option to speed things up. The problem I'm trying to solve is that a single test intermittently fails, which, when run individually succeeds; I suspect this is due to a prior test case not cleaning up properly and would therefore like to be able to identify at a minimum what test cases are in a fork group so that I can take a divide and conquer approach to resolving the issue, even better would be to know which test cases ran before the failing test case. Thanks for your help, Martin.
Re: 'mvn clean test' crashes
Have you tried the more recent version of the Maven surefire plugin? Gary On Wed, Jul 1, 2020, 05:06 Bernd Eckenfels wrote: > Has the machine enough ram free? Did you try a reboot (sometimes windows > memory map seems to be fragmented in a way that java can't start). Does > your Pom overwrite command line and/or specify a very big or very small > heap? Any crash dumps or hs_err files? > > Gruss > Bernd > > > -- > http://bernd.eckenfels.net > > Von: Mukul Gandhi > Gesendet: Wednesday, July 1, 2020 10:47:45 AM > An: Maven Users List > Betreff: Re: 'mvn clean test' crashes > > Hi Enrico, > > On Wed, Jul 1, 2020 at 1:13 PM Enrico Olivelli > wrote: > > > I suggest you to debug that test, with an IDE or just by adding some > > System.out.println > > > > When I run only the tests present in offending java class > (com.haldiram.business.helper.test.ApplnHelperTest), from within the IDE, > all the tests in the class pass. > > But, when I run all the tests present within my aggregated Maven project > (multi module Maven project), using the command 'mvn clean test', the Maven > build failure says following, > > [ERROR] Crashed tests: > [ERROR] com.haldiram.business.helper.test.ApplnHelperTest > [ERROR] at > > org.apache.maven.plugin.surefire.booterclient.ForkStarter.fork(ForkStarter.java:669) > [ERROR] at > > org.apache.maven.plugin.surefire.booterclient.ForkStarter.run(ForkStarter.java:282) > [ERROR] at > > org.apache.maven.plugin.surefire.booterclient.ForkStarter.run(ForkStarter.java:245) > ... > > All of the above, were done on a Windows workstation. > > Also, when a Jenkins build pipeline invokes the command 'mvn clean test' on > a Linux system for all of my same codebase, all the tests pass and Maven > build succeeds there. > > I've a strong feeling that, all my unit tests have no issues from the tests > code perspective. I feel, there could be some other issue, that I'm unable > to solve at this moment. Any further pointers to solve the issues I've > mentioned in this thread would be welcome. > > > > > -- > Regards, > Mukul Gandhi >
Re: 'mvn clean test' crashes
Has the machine enough ram free? Did you try a reboot (sometimes windows memory map seems to be fragmented in a way that java can't start). Does your Pom overwrite command line and/or specify a very big or very small heap? Any crash dumps or hs_err files? Gruss Bernd -- http://bernd.eckenfels.net Von: Mukul Gandhi Gesendet: Wednesday, July 1, 2020 10:47:45 AM An: Maven Users List Betreff: Re: 'mvn clean test' crashes Hi Enrico, On Wed, Jul 1, 2020 at 1:13 PM Enrico Olivelli wrote: > I suggest you to debug that test, with an IDE or just by adding some > System.out.println > When I run only the tests present in offending java class (com.haldiram.business.helper.test.ApplnHelperTest), from within the IDE, all the tests in the class pass. But, when I run all the tests present within my aggregated Maven project (multi module Maven project), using the command 'mvn clean test', the Maven build failure says following, [ERROR] Crashed tests: [ERROR] com.haldiram.business.helper.test.ApplnHelperTest [ERROR] at org.apache.maven.plugin.surefire.booterclient.ForkStarter.fork(ForkStarter.java:669) [ERROR] at org.apache.maven.plugin.surefire.booterclient.ForkStarter.run(ForkStarter.java:282) [ERROR] at org.apache.maven.plugin.surefire.booterclient.ForkStarter.run(ForkStarter.java:245) ... All of the above, were done on a Windows workstation. Also, when a Jenkins build pipeline invokes the command 'mvn clean test' on a Linux system for all of my same codebase, all the tests pass and Maven build succeeds there. I've a strong feeling that, all my unit tests have no issues from the tests code perspective. I feel, there could be some other issue, that I'm unable to solve at this moment. Any further pointers to solve the issues I've mentioned in this thread would be welcome. -- Regards, Mukul Gandhi
Re: 'mvn clean test' crashes
Hi Enrico, On Wed, Jul 1, 2020 at 1:13 PM Enrico Olivelli wrote: > I suggest you to debug that test, with an IDE or just by adding some > System.out.println > When I run only the tests present in offending java class (com.haldiram.business.helper.test.ApplnHelperTest), from within the IDE, all the tests in the class pass. But, when I run all the tests present within my aggregated Maven project (multi module Maven project), using the command 'mvn clean test', the Maven build failure says following, [ERROR] Crashed tests: [ERROR] com.haldiram.business.helper.test.ApplnHelperTest [ERROR] at org.apache.maven.plugin.surefire.booterclient.ForkStarter.fork(ForkStarter.java:669) [ERROR] at org.apache.maven.plugin.surefire.booterclient.ForkStarter.run(ForkStarter.java:282) [ERROR] at org.apache.maven.plugin.surefire.booterclient.ForkStarter.run(ForkStarter.java:245) ... All of the above, were done on a Windows workstation. Also, when a Jenkins build pipeline invokes the command 'mvn clean test' on a Linux system for all of my same codebase, all the tests pass and Maven build succeeds there. I've a strong feeling that, all my unit tests have no issues from the tests code perspective. I feel, there could be some other issue, that I'm unable to solve at this moment. Any further pointers to solve the issues I've mentioned in this thread would be welcome. -- Regards, Mukul Gandhi
Re: 'mvn clean test' crashes
I suggest you to debug that test, with an IDE or just by adding some System.out.println Enrico Il Mer 1 Lug 2020, 09:41 Mukul Gandhi ha scritto: > Hi Enrico, > > On Wed, Jul 1, 2020 at 11:34 AM Enrico Olivelli > wrote: > > > Can you try to run one test at a time and see which test is crashing your > > build? > > > > Use > > mvn test -Dtest=NameOfTheTestClass > > > > When I run all my tests, with command 'mvn clean test', my build failed > with following message, > > [ERROR] Crashed tests: > [ERROR] com.haldiram.business.helper.test.ApplnHelperTest > ... > > When I run only the tests present in class > com.haldiram.business.helper.test.ApplnHelperTest, with following command, > > mvn clean test -Dtest=com.haldiram.business.helper.test.ApplnHelperTest > > The Maven build emits following error, > > [INFO] BUILD FAILURE > [INFO] > > [INFO] Total time: 24.624 s > [INFO] Finished at: 2020-07-01T12:56:40+05:30 > [INFO] > > [ERROR] Failed to execute goal > org.apache.maven.plugins:maven-surefire-plugin:2.22.2:test (default-test) > on project Verimployee-core: No tests were executed! (Set > -DfailIfNoTests=false to ignore this error.) > > Therefore, I run the above command as follows, > > mvn clean test > -Dtest=com.haldiram.business.helper.test.ApplnHelperTest > -DfailIfNoTests=false > > And all the tests present in class > com.haldiram.business.helper.test.ApplnHelperTest pass, and the Maven build > succeeds. > > My problem, that I described originally in this thread, still remains. I > hope, someone may help me further on this issue. > > > > > -- > Regards, > Mukul Gandhi >
Re: 'mvn clean test' crashes
Hi Enrico, On Wed, Jul 1, 2020 at 11:34 AM Enrico Olivelli wrote: > Can you try to run one test at a time and see which test is crashing your > build? > > Use > mvn test -Dtest=NameOfTheTestClass > When I run all my tests, with command 'mvn clean test', my build failed with following message, [ERROR] Crashed tests: [ERROR] com.haldiram.business.helper.test.ApplnHelperTest ... When I run only the tests present in class com.haldiram.business.helper.test.ApplnHelperTest, with following command, mvn clean test -Dtest=com.haldiram.business.helper.test.ApplnHelperTest The Maven build emits following error, [INFO] BUILD FAILURE [INFO] [INFO] Total time: 24.624 s [INFO] Finished at: 2020-07-01T12:56:40+05:30 [INFO] [ERROR] Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.22.2:test (default-test) on project Verimployee-core: No tests were executed! (Set -DfailIfNoTests=false to ignore this error.) Therefore, I run the above command as follows, mvn clean test -Dtest=com.haldiram.business.helper.test.ApplnHelperTest -DfailIfNoTests=false And all the tests present in class com.haldiram.business.helper.test.ApplnHelperTest pass, and the Maven build succeeds. My problem, that I described originally in this thread, still remains. I hope, someone may help me further on this issue. -- Regards, Mukul Gandhi
How to install shaded fat/uber JAR with dependency-reduced POM
Situation (sorry for maybe explaining too much): -- I have a multi-module project with an aggregator POM which is also the parent for all dependent modules. -- The modules implement different byte code transformation features. -- In some modules I use Maven Shade in order build fat JARs which can be used as Java agents. -- Those Java agents add themselves to the bootstrap class path during start-up, utilising the "Boot-Class-Path" manifest entry. For that purpose, it is imperative that the Java agents are fat JARs because their dependencies also need to be on the bootstrap class path, because the byte code transformations can also target other bootstrap classes. This works very well, I have no issues with that. -- Besides, I also build compound source JARs for the shaded JARs, which also works nicely. -- For each JAR I also build a variant with third-party classes relocated to my own package name space, in case the user happens to use the same dependencies and has problems due to API changes which cannot be reconciled by dependency version management. Also here, I build compound source files with relocated source packages. This also works nicely. Problems description: I want users to be able to depend on the shaded agent JARs without pulling other dependencies into their projects because the agent JARs already contain all classes necessary to run them. But if I declare the dependencies as optional in the module using Maven Shade, dependent modules in my own project (e.g. integration test modules) no longer compile in IntelliJ IDEA. This is not a Maven problem, but still something I need to avoid for the sake of being able to use my IDE. As an alternative, I can urge the user to use something like this: xxx yyy * * This is not nice and I do not wish to burden my users with that. What I am currently doing is to use something like this in each module building shaded JARs: org.codehaus.mojo flatten-maven-plugin 1.2.2 flatten process-resources flatten oss remove ${project.build.directory} flattened-pom.xml This has the effect of creating a POM similar to the dependency-reduced POM created by Maven Shade and installing it together with the uber JAR artifact. Now the dependency graph looks "clean" to users of my libraries. I know it is not the Maven way of managin dependencies, but uber JARs with shaded dependencies exist in the real world and I explained at the beginning how/why they are useful in my case. BTW, IntelliJ IDEA still adds all dependencies to the classpath and excludes the uber JAR, trying to be smarter than Maven itself but getting it wrong. But that is not your problem, I can deal with that and provide the path to the uber JAR in another way to my integration tests. The most important thing is that Maven and IDEA do not see the dependencies when using the uber JARs from other project outside of my own multi-module project. Questions: 1. Is there any more canonical way of doing what I did, i.e. directly using the dependency-reduced POM generated by Maven Shade in order to replace the original JAR when installing my artifact? Then I could get rid of the Flatten plugin (which also removes other stuff and even empty lines from my POMs, making them look horrible) and just use Shade. 2. Can I achieve a similar result in a better way altogether? 3. Does anyone even happen to know a way to make this work within my multi-module project in connection with building and running tests with IntelliJ IDEA? BTW, I also experimented with attaching the shaded JARs to the original artifact with special classifiers. This again works with Maven, but not in IDEA. Sorry for the lengthy post, thanks for bearing with me. I really wonder if I am the only one having this kind of problem because I found nothing useful on StackOverflow or doing a global web search. Maybe I did not use the right search terms. -- Alexander Kriegisch https://scrum-master.de - To unsubscribe, e-mail: users-unsubscr...@maven.apache.org For additional commands, e-mail: users-h...@maven.apache.org
Re: 'mvn clean test' crashes
Can you try to run one test at a time and see which test is crashing your build? Use mvn test -Dtest=NameOfTheTestClass Enrico Il Mer 1 Lug 2020, 07:37 Mukul Gandhi ha scritto: > Hi Enrico, > > On Wed, Jul 1, 2020 at 10:47 AM Enrico Olivelli > wrote: > > > > Are you walking System.exit or System.halt in your tests? > > > > I'm not using either of System.exit or System.halt within my tests code. > I'm also neither, using these two statements within my business logic code. > > > > -- > Regards, > Mukul Gandhi >