Skip to content
This repository has been archived by the owner on Apr 29, 2024. It is now read-only.

dockerComposeTest doesn't pick up test resources #36

Closed
dpfeiffer opened this issue Dec 23, 2016 · 4 comments
Closed

dockerComposeTest doesn't pick up test resources #36

dpfeiffer opened this issue Dec 23, 2016 · 4 comments

Comments

@dpfeiffer
Copy link

I have a play application and resources in the test/resources folder which is the default test-resources folder for a play application. If I run a test which accesses test resources from dockerComposeTest the test resources are not on the classpath although they are if I run the same test witch test.

@kurtkopchik
Copy link
Contributor

kurtkopchik commented Dec 23, 2016

Hi @dpfeiffer, the class path for test dependencies is defined in the plugin as an overridable taskKey named testDependenciesClasspath.

testDependenciesClasspath =: // The path to all managed and unmanaged Test and Compile dependencies. This path needs to include the ScalaTest Jar for the tests to execute. This defaults to all managedClasspath and unmanagedClasspath in the Test and fullClasspath in the Compile Scope.

Here is the default implementation:

testDependenciesClasspath := {
  val fullClasspathCompile = (fullClasspath in Compile).value
  val classpathTestManaged = (managedClasspath in Test).value
  val classpathTestUnmanaged = (unmanagedClasspath in Test).value
  (fullClasspathCompile.files ++ classpathTestManaged.files ++ classpathTestUnmanaged.files).map(_.getAbsoluteFile).mkString(":")
}

Is there an additional sbt setting/path that you can append to the default list allow your test resources to be located from your Play application tests? Depending on what the solution is it's possible that the default set of paths I'm building needs to be updated to account for your scenario.

@kurtkopchik
Copy link
Contributor

@dpfeiffer Maybe something like the following:

    testDependenciesClasspath := {
      val fullClasspathCompile = (fullClasspath in Compile).value
      val classpathTestManaged = (managedClasspath in Test).value
      val classpathTestUnmanaged = (unmanagedClasspath in Test).value
      val testResources = (resources in Test).value
      (fullClasspathCompile.files ++ classpathTestManaged.files ++ classpathTestUnmanaged.files ++ testResources).map(_.getAbsoluteFile).mkString(":")
    }

@dpfeiffer
Copy link
Author

@kurtkopchik Thank you for your fast reply, it works as expected when I set the testDependenciesClasspath manually (like you suggested). I should have read the docs more carefully. I think that adding the testResources as a default would suite most scenarios as I assume it's a default behaviour (having access to test resources) for running test.

@kurtkopchik
Copy link
Contributor

Thanks @dpfeiffer! I'm glad that worked for you.

I've published a release that now includes the test resources in the classpath by default when executing dockerComposeTest.

addSbtPlugin("com.tapad" % "sbt-docker-compose" % "1.0.16")

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

No branches or pull requests

2 participants