#IntelliJ JUnit setup

1 messages · Page 1 of 1 (latest)

oblique adder
#

Hello! I am trying to set up my IntelliJ to run JUnit tests. I need to review the tests and their code coverage, but haven’t been able to get the Test Suite to run in IntelliJ. The other developer I am working with uses Eclipse exclusively and I am relatively new to IntelliJ myself. This is a shared repository and I can’t add any automation tools like Gradle, Maven, etc. Advice?

I’d like to avoid a switch to Eclipse if possible

glossy shardBOT
#

<@&987246527741304832> please have a look, thanks.

#

Here is an AI assisted attempt to answer your question 🤖. Maybe it helps! In any case, a human is on the way 👍. To continue talking to the AI, you can use </chatgpt:1108714622413963314>.

#
TJ-Bot
Hello! I am trying to set up my IntelliJ to run JUnit tests. I need to review the tests and their code coverage, but haven’t been able to get the Test Suite to run in IntelliJ. The other developer I am working with uses Eclipse exclusively and I am relativ

ere are some steps you can follow to set up JUnit in IntelliJ:

  1. Make sure you have the JUnit library added to your project. You can do this by going to File > Project Structure > Libraries, then click on the "+" button and select "From Maven..." to search for JUnit.

  2. Create a new JUnit test class by right-clicking on your source folder, selecting New > Java Class, and choosing JUnit 4 test from the dropdown menu.

  3. Write your test methods within this class, making sure to annotate them with @Test.

  4. To run the tests, right-click on the test class file in the project explorer and select Run 'TestClass'.

  5. To view code coverage, go to Run > Edit Configurations, select Defaults > JUnit, and check the box for "Code coverage".

  6. Run your tests again, and you should now see code coverage results in the Run window.

If you are still having issues with setting up JUnit in IntelliJ, please provide more specific details about what errors or challenges you are facing so that we can offer more targeted assistance.

oblique adder
#

I have a JUnit test class given to me and am not given the option to run. Also, please ping me when you reply! I might not see it quickly otherwise

sullen wind
oblique adder
#

Community Edition, working on getting an ultimate license but I’m the only one at my company using IntelliJ at this point (as far as I know everyone else uses eclipse or VSCode)

Need management approval for gradle, maven usage and don’t have it

sullen wind
#

Ultimate has a 30 day free trial.

#

And what, you need management approval to use build tools?

oblique adder
#

If it will add files to the repository, yes

finite anvil
#

can u branch and alter there ?

oblique adder
#

I can’t create a new branch without approval either

sullen wind
#

Wait, how does your colleague manage his dependencies?

#

Do you all just download all jars to your machine, and add them to the classpath? How do you build your jar/war/images/...?

#

And you can always add folders to .gitignore. (assuming you are using a versioning system, and not just copying files).

oblique adder
#

We are using atlassian Bitbucket

sullen wind
#

Are you sure they didn't just mean your dependencies shouldn't be pushed to bitbucket?

oblique adder
#

I’m not sure. I don’t typically work in Java, Im usually scripting in python but got added as a peer reviewer for this

finite anvil
#

if your given the junit it should be on the repo aswell no ?

oblique adder
#

I’m just meant to verify that the JUnit test class covers all cases of the actual code, was gonna run IntelliJ built in code coverage tool but can’t

sullen wind
#

Or just look at sonar if your team has it (or an equivalent).

oblique adder
finite anvil
#

is that test class in the project aswell ?

oblique adder
#

I’m not 100% sure im supposed to even build locally

oblique adder
finite anvil
#

then junit is in the project aswell, else it would be a red hell of errors

oblique adder
#

Fair enough

finite anvil
#

what's on the right click menu of those test class(es) ?

oblique adder
#

Light mode warning

finite anvil
#

can u show more of the actual code ? (if allowed. Not seing any junit stuff )

sullen wind
#

When you right click on the test class itself in the sidebar?

oblique adder
sullen wind
#

Oh boy, ant.

finite anvil
#

makes me wonder, folder not marked as test folder @sullen wind ?

sullen wind
#

It's normal.

finite anvil
#

no icon on the test though

sullen wind
#

I know.

#

You opened/imported the wrong folder.

#

Only do it for SiMServer.

oblique adder
#

Just asked my coworker, it can be set up to build locally but typically isn’t

oblique adder
#

That helped. Def no JUnit in repo, tho

sullen wind
#

Alternatively you can right click on the root folder => module settings => mark test folders.

#

Check the build.xml file to see how it's set up for JUnit.

oblique adder
#

Sorry for photos of a screen, I don’t have discord on my company computer

queen goblet
#

it should be named either something obvious or something with ivy in it

oblique adder
#

I didn’t see anything but my coworker forgot to include the JUnit in the jar file, so once that’s added it might fix it?

sullen wind
#

JUnit is test scoped, so does not end up in the finalr jar.

oblique adder
#

Hhhhm

sullen wind
#

Is there no get-dependencies target?

#

Which usually depends on download/init-ivy.