Should Mockito library already be in the project? (Module 1.4.2)

Hello, module 1.4.2 gets into the business of implementing stuff, and the first check involves a mock with Mockito - the code is described, but the project appears to know thing about Mockito library yet? Is it inferred that I need to install it first?

I can probably (hopefully!) install Mockito no problem, just seems like step hasn’t been mentioned? And sorry if I’ve missed it :slight_smile:

Many thanks,

Simon

2 Likes

@simienrigler I’m a bit confused what it’s about but I’m making an assumption you are doing a certain certification of MoT Automation?

Then @mwinteringham could solve thy question :smiley:

1 Like

Yes Kristof - the course has a link on each module / page which goes straight to The Club with the mot-icta tag already set, so it shows only questions and comments related to the course, and a new question (my question) already had that tag set too - so hopefully i’ve done the right thing?!

2 Likes

For Mark W or anyone - from googling, looks like Mockito’s probably meant to come via the org.junit.jupiter dependency?? and i also added a mockito dependency for good measure - but still getting the ā€˜cannot resolve symbol …’ issues

<dependency>
            <groupId>org.junit.jupiter</groupId>
            <artifactId>junit-jupiter-api</artifactId>
            <version>5.10.2</version>
        </dependency>
        <dependency>
            <groupId>org.mockito</groupId>
            <artifactId>mockito-core</artifactId>
            <version>5.4.0</version>
            <scope>test</scope>
        </dependency>

It does look like I have bigger issues, as the very next check file called ProjectApiTest involves springboot and that’s not being recognised either … help please @mwinteringham !

1 Like

I totally didn’t know this. That’s my bad! :smiley:

1 Like

@simienrigler are you reimporting dependencies in your IDE when you add them? Depending on the IDE dependencies don’t get added automatically.

Hi Mark, thanks for replying. Sorry I’m not sure what I’m doing … do i actually need to add anything to the pom.xml file under dependencies? Or should the file from your github repo be enough as it was? I tried Reload Project as this point.

I’m a bit confused by ā€˜import’ / ā€˜reimport’ term as technically i don’t see those options in menus, but under Maven tool window i do see ā€˜Reload’ projects, and IntelliJ docs guide to this when they talk of ā€˜importing’ …

Right now, after a lot of right-click menu actions within the editors on all the red errors, just steps that were complete guesswork by me and not obvious at all, i’ve now got no errors and a few imports per class - but not convinced this is what you were meaning? Please see screen shots - one for MockedUnitTest and one for ProjectApiTest.

Thanks - and sorry - if the above is wrong, I imagine a 2 minute call would clear up what i’m supposed to be selecting and from where!

Hi,

It’s not clear to me what the error is at this point. Do you mind sending another screenshot with the error in as it might make it easier for me to diagnose.

Hello Mark - to use another example from 1.5.2 - added the LoginPage class code and it has all these unknown references in red. But i am proceeding by hovering over each one then choosing either ā€˜import class’ or 'More actions…` then finding an import. Maybe this is what was meant all along?

And I’ll find out once i get to the end of the Assert section of the course whether this all works after all :slight_smile:

Before

Then resolving each issue one at a time with these imports …

So it looks to me like either the project as a whole hasn’t been imported correctly or IntelliJ needs an SDK setup. What do you see when you head to Project settings > Project and Project settings > SDKs?

Thanks … I downloaded the project from the github repo rather than cloned (trying to avoid some connectivity issues on work machine).

Is this what you’re looking for?

And under SDKs:

And another example from 1.6.3 - the Assert one-liner for the MockedUnitCheck - more methods not recognised without importing further classes … but I think you get the problem now :face_with_diagonal_mouth:

image

Hmmmm and the project is shown to be imported in the maven panel on the right hand side?

I think so …? Does this image show you what you’re looking for?

(And i also tried a clean project into a different directory, following the 2 x README command line instructions, but got the same situation as soon as i tried the MockedUnitTest example file again)

Yeah let’s get togther for a call. This is very strange. Will arrange over DM.

2 Likes