-
Notifications
You must be signed in to change notification settings - Fork 137
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
How to use JUnit in VSCode #658
Comments
Sorry I'm not sure what kind of project it is. It's the java file I create originally/directly from VSCode. |
Hmm, if you don't mind, is it possible for you to share your project with us? |
JunitVSCode.zip Should I modify/configure the files of '.classpath' and '.project'? Or, import the 'junit.jar' into the project? Thank you. |
i'm recommend you use gradle project. its a easy way to run test's, just include junit in build.gradle |
Thank you @SupinePandora43. @yi-yi Yes, As @SupinePandora43 has said, for now, using the build tool: Maven/Gradle could be a workaround to solve your problem. |
Hi, I have the same issue. How to sort this out without Maven/Gradle? I put the junit.jar file in a /lib directory at the same level as my proejct's /bin and /src, but to no avail. If that's correct, I understand I have to set up the classpath. But how to do that? |
you need: (yourJavaFile and lib folder in one folder) |
Hi, thanks, done that, but I am still getting "The import org.junit cannot be resolved". I assume it's a PATH problem but I don't know how to configure it dynamically for each project. |
Thank you for the help @SupinePandora43. @niccolomineo If you still have the classpath problem, that might be related with the Java Language Server. Could you please try to trigger the command |
Thank you jdneo, unfortunately doing so doesn't have any effect. So, ruling out the directory structure problem I have the following questions:
Thank you. |
@niccomineo try to open |
Ok, I put the
|
@niccolomineo NO, i tryed say to don't use |
Can you please attach a dummy project so that I can see what it should be like? It should be able not only to run tests but also to compile java classes. Thanks. |
@niccolomineo wait ~5 minutes |
Thanks, it works now and I'd suggest to somehow add this dummy project to the docs. |
Thank you @SupinePandora43 again for your great work and contribution! Well done!! 👍 @niccolomineo Thank you for your advice, we will consider it! |
Adding this line to the
|
@edelauna It's not recommended to modify the https://code.visualstudio.com/docs/java/java-project#_adding-external-jar |
Just for clarity, here is the file structure from the dummy zip by @niccolomineo, if someone don't want to download a zip file |
It's a question from beginners. I use JUnit in eclipse and IntelliJ. Both of them are designed for JAVA so it's not difficult to find tutorials about setting JUnit environment. But I cann't find any detailed solution on github or stackoverflow. When I insert the
import static org.junit.Assert.*;
at the front of the file, there's an errorThe import org.junit cannot be resolved
.I've downloaded
JUnit.jar
, how to import it into VSCode and configure the classpath of it? Thank you.The text was updated successfully, but these errors were encountered: