Hey, I have a problem with Junit, can someone help me with the code ?
26 Replies
⌛
This post has been reserved for your question.
Hey @Allan! Please useTIP: Narrow down your issue to simple and precise questions to maximize the chance that others will reply in here./close
or theClose Post
button above when your problem is solved. Please remember to follow the help guidelines. This post will be automatically marked as dormant after 300 minutes of inactivity.
Can you show your dependencies?
How are you running the tests?
okay wait
@Allan
still not working
In that case we'll swap to the more traditional approach, let me knab a screenshot
This is the traditional approach in Java Projects, we don't really do test files next to implementation files like you might see in TS/JS land.
yeah but when I add module test it creates another main
in the src
You aren't creating another module
Just a directory
so I have to create a directory test in the src
and is java a directory or package
Not in
/src
, in your case it would be in the root
Both are just folders
They only look special because of IntelliJ
You also need
In your build.gradleokay wait
yeah but when I create a test directory out of src
and create a java directory in the test directory
then it doesn't recognize the imports
and I added
the useJUnitPlatform()
it should be src/test/java normally, not test/java - but using a different structure is possible
This is the structure
ah okay
it doesn't let me choose directory option
In this case package works
It's mostly acting up because you defined the source location in
build.gradle
. /src/main
is the default, so you don't need to specify it.And the
build.gradle
still doesn't work
sadly nothing works
💤
Post marked as dormant
This post has been inactive for over 300 minutes, thus, it has been archived.
If your question was not answered yet, feel free to re-open this post or create a new one.
In case your post is not getting any attention, you can try to use /help ping
.
Warning: abusing this will result in moderative actions taken against you.