Skip to main content

Testing conventions

Simple Story

Here the teacher's own work is under test, so these tests go wrong in their own ways.

The teacher watches anything a test sets up inside the examination as closely as a pupil. When it fails, you cannot tell who failed. A test that needs someone to answer the telephone rings a telephone that is not part of the examination. When nobody answers there, the test counts as skipped, not failed. When the teacher stops a call the rule sheet allows, that is always a failure.

Each test of a rule has two halves: an allowed thing still works, and the teacher still stops a forbidden thing.

Who is who

Every change is verified against all four combinations​

Ares 2 enforces through two independent analysis layers and two independent weaving mechanisms:

AxisOptions
Architecture analysisArchUnit, T. J. Watson Libraries for Analysis (WALA)
aspect-oriented programming (AOP) weavingAspectJ, instrumentation

continuous integration (CI) exercises all four combinations. A change to either layer must be verified against every combination it can affect, and the pull request template asks you to record which ones you exercised. "It passes locally" is not an answer unless you say which of the four you ran.

The profiles​

mvn test # the whole suite
mvn test -Punit-core-tests # unit tests
mvn test -Punit-architecture-tests # architecture unit tests
mvn test -Pintegration-core-tests # core integration tests
mvn test -Dtest=SomeTest#someMethod # a single test

Mutation and order-dependence runs​

Three workflows check the tests themselves rather than Ares. None of them runs on a pull request; start one by hand from the Actions tab of the repository ("Run workflow"). GitHub only offers a workflow once its file is on main, and then lets you pick the branch to run it on.

WorkflowWhat it findsInputs
Mutation Testing (PIT)a small change to the code that no test noticestests, target classes
Mutation Testing (Descartes)a method whose whole body can vanish without a test noticingtests, target classes
Order Dependence (NonDex)a test that passes only while the Java Development Kit (JDK) keeps an order it never promisedtest groups, seeds, first seed

PIT and Descartes use the unit tests by default. The input unit-and-enforcement adds the enforcement integration tests of all four mode combinations, selected together rather than one mode per job as in CI; such a run takes many hours. The input target-classes narrows the run to some classes, for example de.tum.cit.ase.ares.api.io.*. The mutation profile always makes a second, short run without the Ares agent over a fixed list of classes that the agent otherwise loads itself; the summary counts each class from one run only. The run summary shows a table per folder below api, and the run attaches the full reports. Nothing fails because a score is low.

NonDex runs each selected group once as usual and then once per seed with the JDK shuffling what its documentation leaves unordered, such as the iteration order of a HashMap. A job fails when any test fails in any of those runs. Two limits apply:

  • NonDex shuffles only the Java Virtual Machine (JVM) that Surefire starts. Builds and Java processes that a test starts itself, as the core integration tests do, run unshuffled.
  • NonDex replaces part of the JDK with copies of its own. CustomCallgraphBuilderTest checks exactly which jar files a class reaches, so one of its tests fails under NonDex by design. The workflow leaves that one test out, and .github/nondex/excluded-tests.txt says why; the normal CI still runs it.

Tests that need the external echo server skip themselves in these runs, as they do locally. The NonDex summary lists every skipped test. Measured locally, one shuffled run took between 2 and 30 minutes per enforcement mode, the longest with instrumentation.

The same runs locally:

mvn test -Pmutation -DoutputFormats=XML,HTML # PIT
mvn test -Pmutation,mutation-descartes # Descartes
mvn -Punit-core-tests process-test-classes \
edu.illinois:nondex-maven-plugin:nondex -DnondexRuns=3 # NonDex

A fixture must live outside the boundary it helps test​

A sandboxed test Java Virtual Machine (JVM) must never spin up its own server to test incoming or outgoing connections: no echo server, no socket listener, nothing.

The reason is that Ares is the security boundary under test. Any server started inside the same JVM as the student code is itself subject to the active policy, so Ares intercepts its thread, its ServerSocket bind and its accept(). When such a test fails, the failure cannot be attributed: it may be the behaviour under test (the student's client connection, or the student's own server), or it may be the fixture failing to start. The two are indistinguishable from the outside.

The rule that follows:

  • Outgoing-connection tests connect to an external echo server at a configurable endpoint, running as a separate process or CI service on loopback port 25565. The test exercises only the student's client behaviour.
  • If that server is unreachable, the test skips through Assumptions.abort rather than failing. A missing echo server is an expected local condition; CI provides one.
  • An Ares SecurityException on an explicitly allowed connection is always a real failure and must propagate. It is never skipped.
  • Do not hard-code a self-hosted listener as the counterpart. Port 25565 collides easily, and an external service avoids the in-JVM BindException, thread and lifecycle flakiness entirely.

NetworkUser follows this rule: it no longer starts an in-process echo server, and connectLocallyAllowed targets the external server and skips when it is absent.

Both directions of a security assertion​

For a security tool, a green test that only proves "the allowed thing still works" is half a test. Every enforcement change needs both:

  • a positive control, proving the permitted operation is still permitted, so that an over-broad rule is caught;
  • a negative control, proving the forbidden operation is still rejected, so that a regression in enforcement is caught.

The runnable examples under examples/ are written this way: a correct run is green and contains an asserted rejection. A red build there is not the expected outcome.

Structure tests for the documentation​

The documentation has its own tests under src/test/java/de/tum/cit/ase/ares/documentation. They read the Markdown directly, so they run in the ordinary Maven build without Node:

  • every page of both guides is enumerated by an expected path set, so a page cannot be added, removed, renamed or filed under the wrong audience unnoticed;
  • every page declares its front matter, opens with a Simple Story box and carries no h1, and every box except the one on the Who-is-who page ends with the link to that page;
  • every _category_.json is valid and collision-free against its siblings;
  • the policy pages share one shape and together walk the example policy top to bottom.

What they cannot see is whether a page renders. The Playwright suite under documentation/tests covers that.

Notes​

  • Static analysis (spotless, checkstyle, pmd, spotbugs) is a build failure, not a warning. Run it before pushing; see CONTRIBUTING.md.
  • Build with Java Development Kit (JDK) 25 to match CI, even though Ares 2 targets Java 17 so that it stays consumable by exercises on Java 17.