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

Unable to run the same (failing) test twice #104

Closed
bartoszmajsak opened this Issue Aug 9, 2017 · 0 comments

Comments

Projects
None yet
1 participant
@bartoszmajsak
Member

bartoszmajsak commented Aug 9, 2017

Issue Overview

When executing the same test twice, without cleaning target folder between the executions (e.g. from IDEA), Test Bed will fail when trying to store project under test within the project folder.

Expected Behaviour

Test should be executed successfully (and a folder of the project under test persisted without error).

Current Behaviour

Following stacktrace occurs when executing test for the second time from IDEA

Stacktrace from IDEA
java.lang.IllegalStateException: Maven build has failed, see logs for details

	at org.arquillian.smart.testing.ftest.testbed.project.ProjectBuilder.build(ProjectBuilder.java:62)
	at org.arquillian.smart.testing.ftest.testbed.project.ProjectBuilder.run(ProjectBuilder.java:96)
	at org.arquillian.smart.testing.ftest.testbed.project.ProjectBuilder.run(ProjectBuilder.java:92)
	at org.arquillian.smart.testing.ftest.affected.LocalChangesAffectedTestsSelectionExecutionFunctionalTest.should_only_execute_tests_related_to_multiple_local_changes_in_production_code_when_affected_is_enabled(LocalChangesAffectedTestsSelectionExecutionFunctionalTest.java:59)
	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:498)
	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.arquillian.smart.testing.ftest.testbed.rules.TestBed$1.evaluate(TestBed.java:85)
	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.rules.ExternalResource$1.evaluate(ExternalResource.java:48)
	at org.junit.rules.RunRules.evaluate(RunRules.java:20)
	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:68)
	at com.intellij.rt.execution.junit.IdeaTestRunner$Repeater.startRunnerWithArgs(IdeaTestRunner.java:47)
	at com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:242)
	at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:70)
java.lang.RuntimeException: java.nio.file.FileAlreadyExistsException: target/projects/smart-testing-dogfood-repo_LocalChangesAffectedTestsSelectionExecutionFunctionalTest_should_only_execute_tests_related_to_multiple_local_changes_in_production_code_when_affected_is_enabled

	at org.arquillian.smart.testing.ftest.testbed.rules.TestBed.copyTmpProjectInTarget(TestBed.java:70)
	at org.arquillian.smart.testing.ftest.testbed.rules.TestBed.failed(TestBed.java:49)
	at org.arquillian.smart.testing.ftest.testbed.rules.TestBed.failedQuietly(TestBed.java:144)
	at org.arquillian.smart.testing.ftest.testbed.rules.TestBed.access$200(TestBed.java:20)
	at org.arquillian.smart.testing.ftest.testbed.rules.TestBed$1.evaluate(TestBed.java:89)
	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.rules.ExternalResource$1.evaluate(ExternalResource.java:48)
	at org.junit.rules.RunRules.evaluate(RunRules.java:20)
	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:68)
	at com.intellij.rt.execution.junit.IdeaTestRunner$Repeater.startRunnerWithArgs(IdeaTestRunner.java:47)
	at com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:242)
	at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:70)
Caused by: java.nio.file.FileAlreadyExistsException: target/projects/smart-testing-dogfood-repo_LocalChangesAffectedTestsSelectionExecutionFunctionalTest_should_only_execute_tests_related_to_multiple_local_changes_in_production_code_when_affected_is_enabled
	at sun.nio.fs.UnixCopyFile.copy(UnixCopyFile.java:551)
	at sun.nio.fs.UnixFileSystemProvider.copy(UnixFileSystemProvider.java:253)
	at java.nio.file.Files.copy(Files.java:1274)
	at org.arquillian.smart.testing.ftest.testbed.rules.TestBed.copyTmpProjectInTarget(TestBed.java:67)
	... 21 more
Steps To Reproduce

Run selected test twice in IDEA. If it's failing nothing else is needed - it will fail with different error - the same as in detailed stacktrace above. Alternatively, for sucessful test, set test.bed.project.persist system property to true prior to running the test twice in a row.

Additional Information

We can fix it in at least two ways:

  • clean the project if already exists
  • use timestamp as part of the directory structure

with latter, we persist all the executions before wiping target directory. It's a similar approach to how Arquillian persists test deployments so might be worth a shot.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment