This is my current setup:
JavaScript
x
├── src
│ ├── mains
│ │ ├── MainP1.java
│ │ └── MainP2.java
│ └── model
│ ├── Board.java
│ ├── CellStatus.java
│ ├── Coordinate.java
│ ├── exceptions
│ │ ├── BattleshipException.java
│ │ ├── CoordinateAlreadyHitException.java
│ │ ├── InvalidCoordinateException.java
│ │ ├── NextToAnotherCraftException.java
│ │ └── OccupiedCoordinateException.java
│ ├── Orientation.java
│ └── Ship.java
└── test
└── model
├── BoardTest.java
├── CoordinateTestP1.java
├── CoordinateTestP2.java
└── ShipTest.java
I want to be able to run the tests, but VSCode doesn’t detect them:
I have tried creating the following .classpath, but still doesn’t work:
JavaScript
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" path="src"/>
<classpathentry kind="src" path="test"/>
</classpath>
I can run the test in the terminal using:
JavaScript
JFILE="Coordinate.java"; JTEST="CoordinateTestP1.java"; JCLASS="CoordinateTestP1";
javac -cp ./src/ ./src/model/${JFILE} &&
javac -cp ../herramientas/junit-4.13.1.jar:../herramientas/hamcrest-core-1.3.jar:./src/:./test/ ./test/model/${JTEST} &&
java -cp ../herramientas/junit-4.13.1.jar:../herramientas/hamcrest-core-1.3.jar:./src/:./test/ org.junit.runner.JUnitCore model.${JCLASS}
Advertisement
Answer
Update:
There is another more convenient approach: You can configure the classpath of your project if it is a project without build tool support (aka unmanaged folder) by triggering the command Java: Configure Classpath
.
You can try right click the folder test
and select Add Folder to Java Source Path