I'm just starting the computer science program at my college, and I'm having some issues with IntelliJ. When I try to run unit tests, I get the message
Process finished with exit code 1
Class not found: "edu.macalester.comp124.hw0.AreaTest"Empty test suite.
I also see a message entitled "No tests were found" on the left side of my screen. My test code is here:
package edu.macalester.comp124.hw0;
import org.junit.Test;
import static org.junit.Assert.*;
public class AreaTest {
@Test
public void testSquare() {
assertEquals(Area.getSquareArea(3.0), 9.0, 0.001);
}
@Test
public void testCircle() {
assertEquals(Area.getCircleArea(3.0), 28.2743, 0.001);
}
}
And my project code is here:
package edu.macalester.comp124.hw0;
import java.lang.Math;
public class Area {
/**
* Calculates the area of a square.
* @param sideLength The length of the side of a square
* @return The area
*/
public static double getSquareArea(double sideLength) {
// Has been replaced by correct formula
return sideLength * sideLength;
}
/**
* Calculates the area of a circle.
* @param radius The radius of the circle
* @return The area
*/
public static double getCircleArea(double radius) {
// Replaced by correct value
return radius * 2 * Math.PI;
}
}
How can I get my tests to work? I'm using the most recent version of IntelliJ IDEA CE.
In your Maven project structure src/main/java right click on java directory and select option Mark directory as --> Sources Root
Similarly do the same with test directory so: src/test/java right click on java directory and select option Mark directory as --> Test Sources Root
Worked for me :-)
For me it was because my project was being compiled into a directory outside of the project. In paths the output paths were \production\project_name and \test\project_name which was putting them in C:\production\project_name. Changing them to the full path of the project allowed my tests to access the class files.
Was getting same error. My device was not connected to android studio. When I connected to studio. It works. This solves my problem.
I had the same issue (Android Studio 3.2 Canary 4) and I tried most of suggestions described in other answers - without any success. Note this happened after I moved the file from
test
toandroidTest
folder. It was still shown in run configurations as test instead of instrumented test.I finally end up with creating a new file:
This can happen (at least once for me ;) after installing the new version of IntelliJ and the IntelliJ plugins have not yet updated.
You may have to manually do the
Check for updates…
from IntelliJ Help menu.In my case, IntelliJ didn't compile the test sources for a strange reason. I simply modified the build configuration and added the maven goal
clean test-compile
in theBefore launch
section