Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for pomless integration testing #10

Closed
mariuszs opened this issue Oct 25, 2015 · 10 comments
Closed

Add support for pomless integration testing #10

mariuszs opened this issue Oct 25, 2015 · 10 comments

Comments

@mariuszs
Copy link

Currently pomless test fails

[ERROR] The goal you specified requires a project to execute but there is no POM in this directory (/home/mariuszs/git/props2yaml/maven-plugin/target/test-projects/IntegrationTest_testBasic[3.3.3]_pomless). Please verify you invoked Maven from the correct directory. -> [Help 1]
org.apache.maven.lifecycle.MissingProjectException: The goal you specified requires a project to execute but there is no POM in this directory (/home/mariuszs/git/props2yaml/maven-plugin/target/test-projects/IntegrationTest_testBasic[3.3.3]_pomless). Please verify you invoked Maven from the correct directory.
    at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:84)
    at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:307)
    at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:193)
    at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:106)
    at org.apache.maven.cli.MavenCli.execute(MavenCli.java:862)
    at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:286)
    at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:241)
    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 io.takari.maven.testing.executor.Embedded3xLauncher.run(Embedded3xLauncher.java:360)
    at io.takari.maven.testing.executor.MavenExecution.execute(MavenExecution.java:51)
    at io.codearte.props2yaml.maven.IntegrationTest.testBasic(IntegrationTest.java:31)
    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.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50)
    at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
    at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47)
    at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
    at org.junit.rules.TestWatcher$1.evaluate(TestWatcher.java:55)
    at org.junit.rules.RunRules.evaluate(RunRules.java:20)
    at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:325)
    at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:78)
    at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:57)
    at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
    at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
    at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
    at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
    at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
    at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
    at org.junit.runners.Suite.runChild(Suite.java:128)
    at org.junit.runners.Suite.runChild(Suite.java:27)
    at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
    at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
    at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
    at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
    at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
    at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
    at org.junit.runner.JUnitCore.run(JUnitCore.java:137)
    at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:117)
    at com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:234)
    at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:74)
    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 com.intellij.rt.execution.application.AppMain.main(AppMain.java:144)
[ERROR] 
@ifedorenko
Copy link
Contributor

Integration tests harness just runs Maven. If the goal you try to execute requires a project, as the error message appears to suggest, then the test will fail without valid pom.xml. If you believe this is not the case, please provide a small standalone example that runs from command line using mvn but fails when run through the test harness.

@mariuszs
Copy link
Author

Sample minimal project: https://github.com/mariuszs/maven-pomless-plugin

From cli:

$  mvn io.codearte.maven:maven-pomless-plugin:pomless                                                                                                                                                  
[INFO] Scanning for projects...
[INFO]                                                                         
[INFO] ------------------------------------------------------------------------
[INFO] Building Maven Stub Project (No POM) 1
[INFO] ------------------------------------------------------------------------
[INFO] 
[INFO] --- maven-pomless-plugin:1.0-SNAPSHOT:pomless (default-cli) @ standalone-pom ---
[INFO] pomless build succeeded
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 0.158 s
[INFO] Finished at: 2015-10-26T14:00:28+01:00
[INFO] Final Memory: 7M/303M
[INFO] ------------------------------------------------------------------------

@mariuszs
Copy link
Author

Sample build:

https://travis-ci.org/mariuszs/maven-pomless-plugin/builds/87442926

-------------------------------------------------------
 T E S T S
-------------------------------------------------------
Running pomless.IntegrationTest
Tests run: 1, Failures: 1, Errors: 0, Skipped: 0, Time elapsed: 2.431 sec <<< FAILURE! - in pomless.IntegrationTest
testPomlessGoalExecution[3.3.3](pomless.IntegrationTest)  Time elapsed: 2.293 sec  <<< FAILURE!
java.lang.AssertionError: [[ERROR] The goal you specified requires a project to execute but there is no POM in this directory (/home/travis/build/mariuszs/maven-pomless-plugin/target/test-projects/IntegrationTest_testPomlessGoalExecution[3.3.3]). Please verify you invoked Maven from the correct directory. -> [Help 1], [ERROR] , [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/MissingProjectException]
    at org.junit.Assert.fail(Assert.java:88)
    at org.junit.Assert.assertTrue(Assert.java:41)
    at io.takari.maven.testing.executor.MavenExecutionResult.assertErrorFreeLog(MavenExecutionResult.java:44)
    at pomless.IntegrationTest.testPomlessGoalExecution(IntegrationTest.java:30)


Results :

Failed tests: 
  IntegrationTest.testPomlessGoalExecution:30 [[ERROR] The goal you specified requires a project to execute but there is no POM in this directory (/home/travis/build/mariuszs/maven-pomless-plugin/target/test-projects/IntegrationTest_testPomlessGoalExecution[3.3.3]). Please verify you invoked Maven from the correct directory. -> [Help 1], [ERROR] , [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/MissingProjectException]

I hope this helps.

@ifedorenko
Copy link
Contributor

I get exactly the same error running mvn pomless on command line as during the integration test

mpb:tmp igor$ mvn pomless
[INFO] Scanning for projects...
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 0.266 s
[INFO] Finished at: 2015-10-26T09:56:51-04:00
[INFO] Final Memory: 7M/245M
[INFO] ------------------------------------------------------------------------
[ERROR] The goal you specified requires a project to execute but there is no POM in this directory (/private/tmp). Please verify you invoked Maven from the correct directory. -> [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/MissingProjectException

@mariuszs
Copy link
Author

Maybe different maven version, please check logs from new build script:

https://travis-ci.org/mariuszs/maven-pomless-plugin/builds/87551647#L1189

mvn --version                                                                                                                          
Apache Maven 3.3.3 (7994120775791599e205a5524ec3e0dfe41d4a06; 2015-04-22T13:57:37+02:00)
Maven home: /home/mariuszs/sdk/maven
Java version: 1.8.0_60, vendor: Oracle Corporation
Java home: /usr/java/jdk1.8.0_60/jre
Default locale: en_US, platform encoding: UTF-8
OS name: "linux", version: "4.2.3-300.fc23.x86_64", arch: "amd64", family: "unix"

@mariuszs
Copy link
Author

Ok, my test is using wrong goal. Is this any way to make this working?

@ifedorenko
Copy link
Contributor

You need specify fully-qualifier goal name, both on command line and during integration test, i.e. io.codearte.maven:maven-pomless-plugin:1.0-SNAPSHOT:pomless. Of course, don't use literal 1.0-SNAPSHOT in the test, but use project.version test property value.

@mariuszs
Copy link
Author

Thanks!

@mariuszs
Copy link
Author

mariuszs commented Apr 1, 2016

@ifedorenko How to read this project.version inside IntegationTest class?

@mariuszs
Copy link
Author

mariuszs commented Apr 1, 2016

I have found: testProperties.getPluginVersion()

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants