-
Notifications
You must be signed in to change notification settings - Fork 135
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
Single File Test Support #348
Comments
So the workflow might be:
@praenubilus Is this the workflow you want to have to support single file test? |
That looks good. But is there a way to put the dependency into the settings.json? In python plugin, you can configure which test framework you want to use for the workspace, and their path(pytest, unittest etc). I guess the best way here is add a test framework configuration in settings, let user to choose (JUnit, TestNG or other test framework), configure the dependencies path. The setting works either for users or workspace. |
@praenubilus The way to manage the dependency in |
Now the Java Language Server supports to manage the dependencies into the I will start to investigate how to support this kind of project in the Test Runner and unblock those kinds of users. |
I hope you can let the plugin configure a universal default lib/jar path, that means if the user does not explicitly configure a custom lib, jars, classes under that path will always being included by default. Then we can put some default framework jar files under that lib. |
Thank you @praenubilus. About the default lib path, this could be a feature request for https://github.com/eclipse/eclipse.jdt.ls, which is also known as the Java Language Server. And for the testing lib path, I'll consider it. Thank you. |
Now the test runner can run the test even if the project does not have Maven or Gradle. See: The limitation is that there is no Code Lens and cannot explore in the Test Explorer. This issue should be tracked in #470 |
@jdneo thanks for the update. But I'm just a little bit confusing, how does the vscode now where is my junit.jar file? |
Hey @praenubilus, For the projects that do not have |
I'm trying to recreate your test environment @jdneo to run tests from a single file (without the project environment) - unfortunately this causes an error:
The opened folder contains the MyTest.java file with exact the same content as yours and I also added the junit-4.12.jar file to lib folder. I also verified using test runners version 0.16.0. |
@KulowRainer Not sure if you have the same problem like this one: redhat-developer/vscode-java#882 Is the problem still occur if you reload the VS Code? |
Good mention @jdneo, but the problem ist still occurring after reloading VS Code. I also cloud reproduce the same error on a fresh ubuntu 18.04 installation with vs code, meanwhile the screenshot above was taken in Windows 10. |
@KulowRainer Could you please try |
@jdneo Now I can confirm |
@jdneo Any plan for the testing lib path support (other than the lib path from language server) in the near future? |
@praenubilus No such a plan so far at the Test Runner side. I think it should be better to let the Java Language Server support customized classpath for the |
Is there a Document for how Test Discover(JUnit5/4) works for invisible project? In my observation, it seems only working for Test classes at top level (workspace folder), but if I put test Class down to some levels, the test runner cannot discover the unit test classes. Can test Classes in nested folders being explored? Can we specify which folder will be used for test discover? Just like the python plugin, you can specify which folder(s) will be used for test discover. Also, for invisible project lib (I understand it is from Language Server), it looks like symblink will not work, is it correct? |
Would you mind to share a sample project with us? I would like to have a try to see what's happening.
From my observation, no it's not working for a symlink. But I suggest raising the question at the Language Server repo to get the correct answer Thanks |
@jdneo But now any invisible projects, the test runner cannot discover the tests. Even after reinstallation of vscode and all plugins. There is no errors raised for unresolved package, so I assume the jars under lib has been included. But no luck with Test Runner. I have tried another gradle project, it works. Not sure what is wrong, because I do not have any more detailed trace information(does the test runner having such a log? The only prompt I have is:"No test items found."). Here is a sample project I used(works on Ubuntu, but not working on Mac) |
Hi @praenubilus, I took a look at your sample project and find the code is written as: @Test
void myTest() {
assertEquals(1, 1);
} The method |
@jdneo |
@jdneo
HOWEVER, delete the
I can repro this behavior every time through change |
Is the |
By default, it is checked. After I turned it off, the current working space works every time I delete |
Have no ideas so far. If anyone meets the same problem as @praenubilus described, please feel free to let us know. We need to repro it for further investigation. |
@jdneo |
@praenubilus there is no cache for the test discovery. Can you just rename your workspace folder to have a try? rename the workspace folder will force the language server to create new workspace storage. |
@jdneo rename workspace is not working(as I tried). Also to clarify for the linux version, a restart of vscode brings back the codelens and discovered all tests. So the problem only haunting me on Mac. Here I attached a sample project w/ verbose Java Language Server Trace Log(before and after rename workspace), hope that will be helpful to locate the problem. Some other error message from language support for java
|
The plugin currently requires a maven/gradle project to run the unit tests which does not make sense.
Is there a timeline for when single/individual file unit test running will be supported?
The text was updated successfully, but these errors were encountered: