Skip to content
This repository has been archived by the owner on Nov 10, 2017. It is now read-only.

Support debugging unit tests #51

Open
dgileadi opened this issue Jun 22, 2017 · 2 comments
Open

Support debugging unit tests #51

dgileadi opened this issue Jun 22, 2017 · 2 comments

Comments

@dgileadi
Copy link

I'm trying to set up a launch configuration for debugging unit tests, and have hit a wall. I was able to set up my classpath to find the JUnit jar file and launch it. However I'm unable to specify a test file to run. Here's my launch configuration:

        {
            "name": "Run a test",
            "type": "java",
            "request": "launch",
            "jdkPath": "${config:java.home}/bin",
            "sourcePath": ["${workspaceRoot}/src/test/java", "${workspaceRoot}/src/main/java"],
            "cwd": "${workspaceRoot}",
            "startupClass": "org.junit.runner.JUnitCore",
            "options": [
                "-classpath",
                "\"${workspaceRoot}/target/classes:${workspaceRoot}/target/test-classes:/Users/david.gileadi/.m2/repository/junit/junit/4.12/junit-4.12.jar:.\""
            ]
        }

My first thought was to change "startupClass" to include both JUnitCore and my test class, separated by a space. However if I make that change then it's no longer able to start JUnit—it complains:

Error: Could not find or load main class org.junit.runner.JUnitCore path.to.MyTest

Any suggestions?

@faustinoaq
Copy link
Contributor

faustinoaq commented Jun 22, 2017

Remove \" seems that isn't necesary.

"options": [
	"-classpath",
	"${workspaceRoot}/target/classes:${workspaceRoot}/target/test-classes:/Users/david.gileadi/.m2/repository/junit/junit/4.12/junit-4.12.jar:."
]

This problem is already fixed in #45, just waitting to @DonJayamanne to publish a new version 😅

@dueckminor
Copy link

As soon as fix #55 gets published, it will be also possible to specify arguments which will be placed after the startupClass on the java command line. This allows you to select the class which should be tested.

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

No branches or pull requests

3 participants