You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Run test in Code lens in junit test with wrong home location #458
In junit test class, when I click Run test in Code lens, the current run path goes to HOME dir, not current workspace dir.
Run mvn test is correct.
Here is my test class:
`
public class ReportModelTest {
@BeforeClass
public static void before() {
PropertyConfigurator.configure("conf/log4j.conf");
DbUtil.initMysql("conf/mysql.conf");
}
@Test
public void tt() {
System.out.println(new File("./").getAbsolutePath());
System.out.println("Test");
}
@Ignore
public void sum() {
ReportModel.getModel().calculate("2018-11-21");
}
}
`
Part of my log info:
`
[ERROR] at com.microsoft.java.test.runner.Launcher.main(Launcher.java:53)
.
[ERROR] log4j:ERROR Ignoring configuration file [conf/log4j.conf].
.
[INFO] @@<TestRunner-{"name":"testSuiteStarted", "attributes":{"name":"com.adsame.model.mysql.ReportModelTest"}}-TestRunner>
[INFO] @@<TestRunner-{"name":"testStarted", "attributes":{"name":"com.adsame.model.mysql.ReportModelTest#tt"}}-TestRunner>
[INFO] /home/rhett/.
Test
[INFO] @@<TestRunner-{"name":"testFinished", "attributes":{"name":"com.adsame.model.mysql.ReportModelTest#tt", "duration":"1"}}-TestRunner>
[INFO] @@<TestRunner-{"name":"testSuiteFinished", "attributes":{"name":"com.adsame.model.mysql.ReportModelTest"}}-TestRunner>
[INFO] @@<TestRunner-{"name":"testSummary", "attributes":{"message":"Total tests run: 1, Failures: 0, Skips: 0"}}-TestRunner>
Sheng Chen (@jdneo) Yes, it works. You save my life.
By the way, I have three probjects in the current vscode workspace, can it just automaticly pick the right configuration file when run in test class. Now I have to run test method from left side test pannel with right click and choose configration file.
Below is my config:
Sheng Chen (@jdneo) Now I have to use absolute path in launch.test.json, Hope launch.test.json will support variable like "${workspaceFolder}" in launch.json.
Activity
IMEVER commentedon Nov 26, 2018
My vscode-java-test version: 0.11.0
jdneo commentedon Dec 3, 2018
林业天 (@IMEVER)
Try to edit launch.test.json as following:
{ "run": { "default": "<your configuration name>", "items": [ { "name": "<your configuration name>", "projectName": "<your project name>", "workingDirectory": "<the working dir>", "args": [], "vmargs": [], "env": {}, "preLaunchTask": "" } ] }, "debug": { "default": "<your configuration name>", "items": [ { "name": "<your configuration name>", "projectName": "<your project name>", "workingDirectory": "<the working dir>", "args": [], "vmargs": [], "env": {}, "preLaunchTask": "" } ] } }Then set the value of
defaultto the name of the configuration item you want to use.Let me know if this could help with your problem.
IMEVER commentedon Dec 4, 2018
Sheng Chen (@jdneo) Yes, it works. You save my life.
By the way, I have three probjects in the current vscode workspace, can it just automaticly pick the right configuration file when run in test class. Now I have to run test method from left side test pannel with right click and choose configration file.
Below is my config:
{ "run": { "default": "MobileTracker-Report", "items": [ { "name": "MobileTrackerServer", "projectName": "MobileTrackerServer", "workingDirectory": "/data/code/java/TransferParameter/MobileTrackerServer", "args": [], "vmargs": [], "env": {}, "preLaunchTask": "" }, { "name": "MobileTrackerReport", "projectName": "MobileTrackerReport", "workingDirectory": "/data/code/java/TransferParameter/MobileTrackerReport", "args": [], "vmargs": [], "env": {}, "preLaunchTask": "" }, { "name": "MobileTracker-Report", "projectName": "MobileTracker-Report", "workingDirectory": "/data/code/java/TransferParameter/MobileTracker-Report", "args": [], "vmargs": [], "env": {}, "preLaunchTask": "" } ] } }IMEVER commentedon Dec 4, 2018
Sheng Chen (@jdneo) Now I have to use absolute path in launch.test.json, Hope launch.test.json will support variable like "${workspaceFolder}" in launch.json.
jdneo commentedon Dec 4, 2018
林业天 (@IMEVER) Glad to know problems are resolved.