6.031
6.031 — Software Construction
Spring 2021

Automated Testing

Starting with Problem Set 0, you have been using the Didit system for automated building and testing: every time you push your commits to GitHub, the Didit build server pulls a copy of your code, attempts to compile it, and runs tests.

This kind of automation is very common in the world of professional software development, and is very useful for coordinating a team of developers. There is no ambiguity about whether the code compiles or not: if it doesn’t compile on the build server, it doesn’t compile. And there is no ambiguity about whether the tests pass: if they don’t pass on the build server, they don’t pass.

Naming

For this project, Didit will run your tests: any JUnit tests you check in to your team’s project repository will be executed and the results included in your Didit build report. Tests must be in the test directory with a name like SomethingTest.java or SomethingTests.java for Didit to find them.

Restrictions

Your tests will be run in an environment with limited permissions and resources:

  • Your code runs with read-only filesystem access, so that your tests can load puzzle files.

  • Your code may listen on and connect to localhost ports 8700—8799, so that your tests can communicate with your server and/or client.

  • There is no GUI support.

An attempt to circumvent these restrictions is a violation of course policy and academic standards and will be dealt with harshly.

However, if you find that Didit is unable to run some of your tests, but you think they are reasonable and should be supported, post on Piazza with “Didit test restrictions” in the subject line. Hopefully we will be able to make Didit more accommodating.

Excluding tests

You may have some tests that Didit cannot run. Don’t let Didit’s restrictions stop you from writing such tests. Instead, for these tests, use the annotation @Tag("no-didit") to skip them on Didit. You can annotate an entire class with @Tag("no-didit"), or individual test methods.

For example:

package starb;

import org.junit.jupiter.api.Tag;
import org.junit.jupiter.api.Test;

/**
 * Test puzzles.
 */
public class PuzzleTest {

    @Test
    public void testNYTimesMonday() {
        // runs on Didit
    }

    @Test @Tag("no-didit")
    public void testNYTimesSaturday() {
        // will not run on Didit
    }
}

On your build results page, Didit will report which tests it ran and which tests it skipped. Make sure you and your teammates are running the skipped tests manually.