Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Running tests on Intellij: Class not found

I'm evaluating IntelliJ (13.0.2 133.696) and cannot get jUnit tests to run from within the IDE.

My project is a multi module gradle project and uses scala.

Test class is located under src/test/scala/xxx/xxxxx/xxx/xxxx/xxxxx and everytime i try to run from IDE i get the same error:

Class not found: "xxx.xxxxx.xxx.xxxx.xxxxx.AccountRepositoryTest" 

Test class is nothing fancy, simple jUnit test:

@RunWith(classOf[SpringJUnit4ClassRunner]) @ContextConfiguration(classes = Array(classOf[DataConfig], classOf[SettingsConfig])) class AccountRepositoryTest extends AssertionsForJUnit { 

I've found a related question Cannot run Junit tests from IDEA 13.0 IDE for imported gradle projects , but the provided fix (upgrade to 13.0.2) does not work.

I've even tried upgrading to the latest EAP, still the same issue.

like image 308
gerasalus Avatar asked Feb 28 '14 20:02

gerasalus


People also ask

Can not run test IntelliJ?

Check in Project settings -> Modules that you test package is marked as Tests. Right click on the test class name either in the code window or in the project panel, and select Run <classname>. If you don't see the run menu in the popup then you haven't selected a test or you don't have junit plugin installed.

How do I get to test class in IntelliJ?

You can use ⇧⌘T (macOS), or Ctrl+Shift+T (Windows/Linux), to navigate to a test class and back again.


1 Answers

I looked through some of these answers, fussed with Project Settings, tried a few things, etc. and nothing worked. (Full disclosure: I'm not trying to juggle Gradle here; I'm just using Maven, but I don't see what this has to do with Gradle.)

I'm using IDEA 14.

What I found to work, because it just simply seemed IntelliJ had lost its way, was this:

$ rm -rf .idea project-name.iml 

Then relaunched IntelliJ and did File -> Open -> navigate to the root of my project, etc.--in short, just recreated my project.

IntelliJ got over it. I may have messed something up originally in this project as I had done plenty of refactoring both package- and class names and I had even changed the project name. (It was probably my fault it happened.)

like image 186
Russ Bateman Avatar answered Sep 23 '22 20:09

Russ Bateman