Grade Java code without punishing a typo twice
Structural tests normally fail completely when a student misspells a method name. The Levenshtein Testing Framework is forgiving about names and strict about the rest: it matches classes, methods and attributes by fuzzy name, so a misspelled name costs only the structural point for that element, while every behavioural test still runs against the misspelled member. In exams, students are not punished twice for one typo, and the grade shows what they understood, not whether they typed carefully. In practice and learning exercises, the feedback points to the typo instead of failing every test, so beginners keep going instead of giving up on a missing semicolon-sized mistake. Built on Ares 2 for exercises and exams on Artemis.
GitHub · Documentation · API reference · Maven Central

Quick example: a class accepted as a deviation
The exercise asks for class Truck extends AbstractVehicle. A student writes class Truck extends Car, where Car extends AbstractVehicle. The framework does not fail the class: Truck is found, and its behavioural tests all run. The structure test reports one deviation:
⚠️ DEVIATION ⚠️
If possible actual will be used for further testing in package io.github.valentinherrmann.example.vehicles
Expect: public class Truck extends AbstractVehicle
Actual: public class Truck extends Car
Inheritance is compared by the classes the wrappers found, not by name:
| Student code | Superclass verdict |
|---|---|
Truck extends AbstractVehicle |
✓ EXACT |
Truck extends AbstractVehical (typo) |
✓ EXACT for Truck; the typo is reported once, as a deviation of AbstractVehicle itself |
Truck extends Car extends AbstractVehicle (indirect) |
⚠ DEVIATES |
| extra interface, or interface only inherited | ⚠ DEVIATES |
| unrelated superclass, or none | ❌ MISSING |
What counts as a deviation
The distance between two names is the Levenshtein distance divided by the longer name. Up to 20 % (configurable per element kind) the closest candidate is taken. Types are graded separately.
| Expected | Student wrote | Why | Verdict |
|---|---|---|---|
private double price |
private double prize |
name, 20 % | ⚠ DEVIATES |
public double getPrice() |
public double getPrise() |
name, 12.5 % | ⚠ DEVIATES |
public void start() |
public void strat() |
name, 40 % | ❌ MISSING |
int year |
Integer year |
primitive ⇄ wrapper | ⚠ DEVIATES |
int year |
long year |
numeric type | ⚠ DEVIATES |
double speed |
int speed |
numeric type | ⚠ DEVIATES |
Car car |
AbstractVehicle car |
student’s type is a supertype | ⚠ DEVIATES |
AbstractVehicle vehicle |
Car vehicle |
student’s type is a subtype | ❌ MISSING |
int seats |
boolean seats |
unrelated type | ❌ MISSING |
public int getYear() |
protected long getYear() |
modifier and return type | ⚠ DEVIATES |
Modifiers never make an element MISSING, and "final?" makes a modifier optional. Methods are found by name and parameter types together, so overloads work. Class names are also tried with other spellings (first letter case, plural or singular, swapped letters).
What students see
Every failure uses one format, without stack traces. Structure first:
⚠️ DEVIATION in Car ⚠️
If possible actual will be used for further testing.
Expect: private double price
Actual: private double prize
❌ MISSING in Car ❌
Expect: public void start()
Then behaviour, with method, scenario, input, expected and actual value:
Method: setPrice(double)
Scenario: setter -> attribute, attribute price
Input: setPrice(-1.25)
Expected: value rejected (unchanged 2.50 or exception)
Actual: -1.25
(2 of 15 cases failed)
Exceptions in student code become the same block, with the exception type and message instead of a stack trace. A StackOverflowError adds a hint about endless recursion. Long arrays and lists are shortened. Feedback is available in German and English.
Getters and setters in one line
car.testGettersSetters(car.price(), car.getPrice(), car.setPrice());
car.testGettersSetters(car.price(), (Double p) -> p >= 0, car.getPrice(), car.setPrice());
car.testGettersSetters(car.price(), List.of(1.5, 99.0, 0.0), car.setPrice());
Generated values, three subtests (setter → attribute, attribute → getter, setter → getter), each on a new instance. An optional condition says which values must be stored and which must be rejected.
Mocking, even for deviating elements
Tests can build objects without running the student’s constructor, replace methods with test-owned ones, and check that a method was called. This works on misspelled and inherited members too: the framework overrides the element it actually found, so a student’s getPowr() is mocked just like getPower(). Argument and return types are converted automatically, so args -> 7 works for a double method.
Mock<?> engine = engineWrapper.mock()
.override(engineWrapper.getPower(), args -> 120);
Object car = carWrapper.newObjWithoutConstructor();
carWrapper.engine().setValue(car, engine.obj());
assertThat(carWrapper.getTopSpeed().invokeOnSpecificObject(car)).isEqualTo(240);
engine.assertCalled(engineWrapper.getPower(), 1,
() -> "Car.getTopSpeed() must use getPower() of its engine.");
A bug in Engine then cannot fail the test of Car.getTopSpeed(). Further options: returning(method, value), othersReturnDefaults(), callCount, calls, assertNotCalled, resetCalls. Final, static and private members and constructors cannot be replaced; the framework then says so in a readable message. Details: Independent Tests and Mocks.
All features
Structure
- Fuzzy matching of classes, methods, attributes and constructors; the closest candidate wins.
- Modifiers, types, superclass and interfaces are checked; optional modifiers with
"final?". - Student classes as attribute, return or parameter types, found with the same tolerance.
- Four detail levels: one test for everything, per class, per member category, or per member.
- Name thresholds per element kind,
IGNOREorDEVIATEfor unexpected modifiers.
Behaviour
- Wrappers call the element that was found; a missing element fails with “not implemented as expected”.
- Numeric values are converted to the student’s type (
int,long,float, …). invokeExpectingExceptionfor tests that must throw; static members; lazily built scenario texts.- Abstract classes and interfaces through Byte Buddy subclasses, using the real (even
protected) constructor. - Getter/setter tests with generated values and setter conditions.
Independent tests
- Objects without constructor, method overrides and call checks (
mock()), also on deviating members.
Reporting
- One format: Method, Scenario, Input, Expected, Actual, case count; also for your own checks via
Failure. - German and English messages, configurable decimals.
Exams and exercises
- Exercise Variants: names and types in one
Constantsclass. @LevenshteinTestand@HiddenLevenshteinTestwith timeout (default 5 s) and Ares 2 supervision.- Static state of the student’s classes is reset between tests.
- Gradle and Maven templates, with a passing and a failing example solution.
Requires JDK 25 and Gradle 9.1+ or Maven 3.9+.