Running TestNG Test in IntelliJ
Asked Answered
O

4

6

After running Rebuild Project successfully in IntelliJ 13.1.3 Ultimate IDE, I opened my Test NG test file.

When right-clicking on the file, I don't see any option to run the test.

How can I run an TestNG test in IntelliJ 13.1.3?

This question is similar, but it's from 2012 with an unaccepted answer.

Orate answered 8/7, 2014 at 14:19 Comment(1)
What do you see? Any run menu option at all? When that happens for me sometimes waiting a minute fixes it... :| Also removing .iml and .IDEA folder sometimes fixes itNecrophilism
S
6

Yes you can!

Сheck the folder that contains the test classes whether marked as Test Source Root. In another case see whether installed TestNG-J plugin.

Update:

enter image description here

Selfconfidence answered 9/7, 2014 at 16:33 Comment(2)
Hmm, for my module I verified that src/test/java was listed as a Test Source Folder per your link, but I get 0 test class found in package xyz when trying to run the test from IntelliJ.Orate
@KevinMeredith You can run all test class as is present in screenshot ? See updates.Selfconfidence
L
3

There are 3 possibilities in the new Intellij 2017.2 to run a testNG test.

  1. You can click on the module (project) name >>Run>>All Tests(TNG). Be careful as there are 2 'All Tests' options. The second option is the one you need. It carries a testNG logo. This way you can run all your testNG classes in parallel

  2. The second possibility is to run a single TestNG class. Righ click the class name in the package explorer and choose 'Run Test' If your class is a testNG class, by default, the test will run as a TestNG test.

  3. This option is my favourite as it gives me a lot of control over my tests. Install this 'Create TestNG XML' plugin. Once installed. if you right click on your module name, you will see a new option called 'Create TESTNG XML' and you will be able to directly use that option to run your TestNG tests, giving you a lot of flexibility.

Lexicologist answered 8/10, 2017 at 16:39 Comment(0)
D
1

It could be that a plugin that you need is disabled.

Make sure the testNg plugin is enabled.

I noticed this plugin wasn't enabled, and as soon as I turned it on, everything started working.

Digraph answered 23/4, 2021 at 15:24 Comment(0)
E
0

Besides possible reasons outlined in the rest of responses, there is also one other possible alternative scenario where tests are not "found".

Make sure that your test classes are of public scope. If they are package protected, they won't be found by IntelliJ plugin (but they will be executed via Maven).

Easley answered 25/10, 2023 at 8:0 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.