TestLang++

A compiler-driven DSL for fast, consistent HTTP API test generation.

TestLang++

Technologies Used

JavaJFlexCUPJUnit 5HttpClientCompiler Design

Problem

API tests can become repetitive and inconsistent when every endpoint test is manually coded in Java. Teams lose time on boilerplate setup and debugging brittle test files.

Solution

TestLang++ introduces a concise test language where developers write readable .test files that compile to JUnit 5 classes. The generated tests use HttpClient and assertion patterns that are reliable and easy to maintain.

Results and Impact

  • Reduced repetitive test setup by expressing requests and assertions declaratively.
  • Improved reliability through typed declarations and semantic validation in the compiler pipeline.
  • Increased debugging speed using line-numbered diagnostics for parser and semantic errors.

Key Features

Declarative Test Syntax

Write HTTP tests in simple .test files with config, variables, requests, and assertions

Full Compiler Pipeline

Scanner, parser, type checker, and code generator with comprehensive error handling

JUnit 5 Generation

Each test block becomes a @Test method with HttpClient requests and assertions

Rich Assertions

Status codes, headers, and body content validation with contains/equals semantics

HTTP Methods Support

GET, POST, PUT, DELETE with custom headers and request bodies

Variable Interpolation

Define string or integer variables with let and reference them using $name syntax

Challenges

  • Designing grammar rules that stay expressive but unambiguous.
  • Ensuring semantic checks catch invalid types early before generation.
  • Generating readable Java test output without sacrificing correctness.

Language Structure

Configuration Block

Optional global settings for base URL and default headers

config {
  base_url = "http://localhost:8080";
  header "Content-Type" = "application/json";
}

Variable Declarations

Define reusable values with type safety

let userId = 123;
let token = "Bearer abc123";

Test Blocks

Each test includes requests and assertions

test LoginTest {
  POST "/api/login" {
    body = "{\"username\":\"admin\"}";
  };
  expect status = 200;
  expect body contains "token";
}

Project Links

Replace these placeholders with your real repository and demo video URLs.