TestKit Setup

Last updated on 16th July 2024

Creating a test file

Typically, unit tests are created in a separate source folder to keep the test code separate from the rest of the code base. The standard convention is to use

  • src/main/java - for Java classes
  • src/test/java - for test classes

Each class should have a test class created for tests. The name of the test file should be the name of the class being tested with the word “Test” suffixed.

For example, when creating a test file for the Agent Trader.java, in directory src/main/java/model/Trader.java, the test file should be named TraderTest.java in directory src/test/java/model/TraderTest.java.

Dependency

To use the Simudyne SDK TestKit with a new project, you can start your project from one of the quickstart projects, preconfigured for using the TestKit. To use the Simudyne SDK TestKit with an existing project, you must add the following dependency in your project:

pom.xml

<dependencies>
    <dependency>
        <groupId>simudyne</groupId>
        <artifactId>simudyne-core-abm-testkit_2.11</artifactId>
        <version>${simudyne.version}</version>
    </dependency>
</dependencies>

You will also need to use a testing framework with the TestKit. In this guide, we will be using JUnit. To use JUnit, add the following dependency to your project:

pom.xml

<dependencies>
    <dependency>
        <groupId>junit</groupId>
        <artifactId>junit</artifactId>
        <version>4.12</version>
        <scope>test</scope>
    </dependency>
</dependencies>