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.
This will also happen when your module- and/or project-jdk aren't properly configured.
I had the same issue. In my case i had some test classes in a package/folder outside of the main folder. But when i checked the Run configuration, it was always trying to look for classes inside the main folder (and not my packages outside of main) . So if that is the case , you either have to move your packages to where the Run configuration is pointing to. Or change the run configuration to point to your packages.
In my case, the problem was fixed by going into my
build.gradle
and changingto
Deleting
.idea
and re-importing the SBT project solved this issue for me.I had the same problem and rebuilding/invalidating cache etc. didn't work. Seems like that's just a bug in Android Studio...
A temporary solution is just to run your unit tests from the command line with:
See: https://developer.android.com/studio/test/command-line.html
Had the same message. I had to remove the Run/Debug configuration.
In my case, I ran the unit test as a local test before. After that I moved my test to the androidTest package and tried to run it again. Android Studio remembered the last run configuration so it tried to run it again as a local unit test which produced the same error.
After removing the config and running the test again it generated a new configuration and worked.