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

Error: Could not find or load main class org.scalatest.tools.Runner #73

Closed
mb720 opened this issue May 19, 2017 · 2 comments
Closed

Error: Could not find or load main class org.scalatest.tools.Runner #73

mb720 opened this issue May 19, 2017 · 2 comments

Comments

@mb720
Copy link

mb720 commented May 19, 2017

Hi!

I'm getting the error

Could not find or load main class org.scalatest.tools.Runner

when trying to run my tests using dockerComposeTest.

The tests run fine when run from SBT using test.

I added testExecutionArgs := s"-R ${baseDirectory.value}/target/scala-2.12/test-classes" thinking that maybe ScalaTest can't find the classes when being started using the plugin but that didn't help.

I also tried to add all the class files to my docker-compose.yml by adding this to build.sbt to no avail (I'm using JavaAppPackaging):

  val targetDir = "/app/"
  new Dockerfile {
    
    from("java:8-jre")

    val classpath = (fullClasspath in Test).value
    add(classpath.files, targetDir)
    // ...

My build.sbt is here: https://gitlab.com/bullbytes/scala-js-example

Thanks, any help is appreciated.

@kurtkopchik
Copy link
Contributor

Hi @mb720!

The first thing to do would be to upgrade to the latest version of sbt-docker-compose as I see you are on version 17 instead of version 22. There were a number of enhancements made since the version that you are using.

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

With this latest release, I'm not 100% certain, but you can probably now remove the following line from your build.sbt file as there is enhanced support for network removal:
dockerMachineName := s"${BuildConfig.appName}-network"

Additionally, you are going to need to define the following setting to provide the proper test configuration file for when your tests are run via dockerComposeTest:
testExecutionExtraConfigTask := Map("config.file" -> s"${sourceDirectory.value}/test/resources/application.test.conf")

With those changes I was able to successfully execute dockerComoseTest from within the appJVM project. If you are still seeing an issue please send the full output from and we can dig into it further.

scala-js-example kurtkopchik$ sbt
[info] Loading global plugins from /Users/kurtkopchik/.sbt/0.13/plugins
[info] Loading project definition from /Users/kurtkopchik/Source/scala-js-example/project
[info] Set current project to scala-js-example root (in build file:/Users/kurtkopchik/Source/scala-js-example/)
> project appJVM
[info] Set current project to scala-js-example (in build file:/Users/kurtkopchik/Source/scala-js-example/)
> dockerComposeTest skipPull
Starting Test Pass against a new local Docker Compose instance.
Building a new Docker image.
[info] Wrote /Users/kurtkopchik/Source/scala-js-example/app/jvm/target/scala-2.12/scala-js-example_2.12-0.0.1.pom
[info] Sending build context to Docker daemon 38.17 MB
[info]
[info] Step 1/4 : FROM java:8-jre
[info]  ---> e44d62cf8862
[info] Step 2/4 : ENTRYPOINT /app/bin/scala-js-example
[info]  ---> Using cache
[info]  ---> 7e7ea3319c32
[info] Step 3/4 : COPY 0/stage /app
[info]  ---> Using cache
[info]  ---> 303fec02d4a2
[info] Step 4/4 : RUN mkdir -p /logs
[info]  ---> Using cache
[info]  ---> 9528cad186e5
[info] Successfully built 9528cad186e5
[info] Tagging image 9528cad186e5 with name: registry.gitlab.com/bullbytes/scala-js-example:latest
Creating Local Docker Compose Environment.
Reading Compose File: /Users/kurtkopchik/Source/scala-js-example/app/jvm/../../docker-compose.yml
Created Compose File with Processed Custom Tags: /var/folders/gy/swztjnld0cz0dm9s_45j_x0h0000gp/T/compose-updated6384060063410476934.yml
'skipPull' argument supplied. Skipping Docker Repository Pull for all images. Using locally cached version of images.
Creating network "161905_scala-js-example-network" with driver "bridge"
Creating volume "161905_postgresVolume" with default driver
Creating 161905_db_1
Creating 161905_web_1
Waiting for container Id to be available for service 'web' time remaining: 499
web Container Id: 529cf9489088
Inspecting container 529cf9489088 to get the port mappings
Docker for Mac environment detected. Using the localhost for the container.
Waiting for container Id to be available for service 'db' time remaining: 499
db Container Id: fcd7bbf09acc
Inspecting container fcd7bbf09acc to get the port mappings
Docker for Mac environment detected. Using the localhost for the container.

The following endpoints are available for your local instance: 161905
+---------+------------------+-------------+--------------+----------------+--------------+---------+
| Service | Host:Port        | Tag Version | Image Source | Container Port | Container Id | IsDebug |
+=========+==================+=============+==============+================+==============+=========+
| db      | localhost:<none> | 9.6.1       | cache        | <none>         | fcd7bbf09acc |         |
| web     | localhost:5005   | latest      | cache        | 5005           | 529cf9489088 |         |
| web     | localhost:80     | latest      | cache        | 8080           | 529cf9489088 |         |
+---------+------------------+-------------+--------------+----------------+--------------+---------+
Instance commands:
1) To stop instance from sbt run:
   dockerComposeStop 161905
2) To open a command shell from bash run:
   docker exec -it <Container Id> bash
3) To view log files from bash run:
   docker-compose -p 161905 -f /var/folders/gy/swztjnld0cz0dm9s_45j_x0h0000gp/T/compose-updated6384060063410476934.yml logs -f
4) To execute test cases against instance from sbt run:
   dockerComposeTest 161905
Compiling and Packaging test cases...
Discovery starting.
Discovery completed in 1 second, 163 milliseconds.
Run starting. Expected test count is: 4
PeopleSpec:
The people service
- should return OK if requesting the people form page
- should return non-empty content when requesting the people form page
- should return the expected content when requesting the people form page
- should leave GET requests to other paths unhandled
Run completed in 2 seconds, 945 milliseconds.
Total number of tests run: 4
Suites: completed 2, aborted 0
Tests: succeeded 4, failed 0, canceled 0, ignored 0, pending 0
All tests passed.
Stopping and removing local Docker instance: 161905
Stopping 161905_web_1 ... done
Stopping 161905_db_1 ... done
Removing 161905_web_1 ... done
Removing 161905_db_1 ... done
Going to remove 161905_web_1, 161905_db_1
161905_scala-js-example-network
>

@mb720
Copy link
Author

mb720 commented May 20, 2017

Hi Kurt!

Thanks a ton for your quick and helpful reply!

Indeed, upgrading to the plugin's current version fixed the Could not find or load main class org.scalatest.tools.Runner problem.

You were also right with the other two fixes.

@mb720 mb720 closed this as completed May 20, 2017
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