Amomum
Amomum

Reputation: 6493

Junit test in IntelliJ IDE can't see class for testing

I created simple Java project in IntelliJ, one class (RandomizedQueue) and generated JUnit test class for it. So it's just two files and they both are in the same directory - src.

Everything compiled and all was well. For some time. Then suddenly - it stopped with this error:

java: cannot find symbol
  symbol:   class RandomizedQueue
  location: class RandomizedQueueTest

I tried everything I could think of. Recreating a project worked for a while but the same error reappeared (without any obvious reason). I can't find any logic in this! Compilation from cmd does work.

I tried deleting everything from class and test - and I still can't make an instance in test method.

here is the whole project

Upvotes: 13

Views: 14580

Answers (3)

BStride
BStride

Reputation: 31

I had the same problem. I fixed it by rebuilding the package in which the tests were located. Right click on the package and select "rebuild 'package name'".

Upvotes: 2

Paulo Merson
Paulo Merson

Reputation: 14477

I have the same issue every once in a while in my gradle projects (I'm on IntelliJ 2018.2.4 now).

The solution is to open a terminal and execute gradlew idea.

Upvotes: 0

kukido
kukido

Reputation: 10601

See those white x-es next to the class name?

enter image description here

Somehow you have excluded RandomizedQueue class from the compilation.

enter image description here

Remove it from the excludes and everything will be back to where it was before.

PS: Coursera FTW :-)

Upvotes: 10

Related Questions