unit testing error
I wrote this unit test: but I'm getting this error:
38 Replies
⌛
This post has been reserved for your question.
Hey @IamMax420! 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.
💤
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.
try to annotate it with springboottest instead of what u have
💤
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.
now I get this:
show the code
i mean the test
if you wanna use mockmvc
you also need that annotation
also if you wanna test the controller you shouldnt use mockito on customer service
because you wanna test the whole flow
controller service database
so you load an actual object
so you dont really need customer service at all here
not sure if I understand right:
u mean something like this?
get rid of customer service
now I'm getting this:
also you probably shouldnt put your real name in tests
Ik
show the
class again
after you deleted the service in the test
also make sure src/main/java and src/test/java have the same packages
so If I have a package named "config" in the /main dir, I have to create it in the /test dir even if I'm not planning on testing it now?
or what
no
show the screenshot of the classes
if you can
if you cant make sure the package customer controller is in main java is the same as in test java

it is there
hmmmmmmmmmmmmm
package name shouldnt be uppercase btw
MaxLibrary
as for the test
can you check if
max library application test works
or if you get the same error
alright I renamed it

still getting an error tho:
oh
lol
ok so
you see that package named
com.max420.maxlibrary
in src java
place all the folders in it
so config controllers dto models repository services
it should be in that package
and in your test java package
move the controllers folder to com.max420.maxlibrary
then send a screenshot of how it looks
ok I figured it out
just had to add the "classes = "
yea but you could do it without specifying the class
because you have a
quite interesting project structure
if you did my suggestion u wouldnt need to specify the class
u can try it out if ur curious
ohhh shit
so you generally have to put all the packages into the com.blahblah package
well yes
r u learning from a tutorial or a course btw
if its a course u should ask the instructor how project structure should look like
basically like this yea
I watched some course from freeCodeCamp some time ago and the guy was creating a bunch of separate packages
but apparently thats not what you're supposed to do
yea i guess

look
i took it from some example
ignore the serverlet initializer
thats how it looks
well thanks for the help dude
If you are finished with your post, please close it.
If you are not, please ignore this message.
Note that you will not be able to send further messages here after this post have been closed but you will be able to create new posts.
Post Closed
This post has been closed by <@589517424093691905>.