Testing guide
Running tests
There are two ways to run tests.
- Method 1: Using IntelliJ JUnit test runner
- To run all tests, right-click on the
src/test/java
folder and chooseRun 'All Tests'
- To run a subset of tests, you can right-click on a test package,
test class, or a test and choose
Run 'ABC'
- To run all tests, right-click on the
- Method 2: Using Gradle
- Open a console and run the command
gradlew clean test
(Mac/Linux:./gradlew clean test
)
- Open a console and run the command
-
Method 3: Using Gradle (headless)
-
Thanks to the https://github.com/TestFX/TestFX[TestFX] library we use, our GUI tests can be run in the headless mode. In the headless mode, GUI tests do not show up on the screen. That means the developer can do other things on the Computer while the tests are running.
-
To run tests in headless mode, open a console and run the command
gradlew clean headless test
(Mac/Linux:./gradlew clean headless test
)
-
Types of tests
This project has two types of tests:
- GUI Tests - These are tests involving the GUI. They include:
- Unit tests that test the individual components. These are in
chopchop.address.ui
package.
- Unit tests that test the individual components. These are in
- Non-GUI Tests - These are tests not involving the GUI. They include:
- Unit tests targeting the lowest level methods/classes.
e.g.chopchop.commons.StringUtilTest
- Integration tests that are checking the integration of multiple code units (those code units are assumed to be working).
e.g.chopchop.storage.StorageManagerTest
- Hybrids of unit and integration tests. These test are checking multiple code units as well as how the are connected together.
e.g.chopchop.logic.CommandParserTest
- Unit tests targeting the lowest level methods/classes.