Skip to content
CodeKruPro

Port your harness to Java or JavaScript

91/99

Module · Frameworks and other languages

advanced

about 40 min

What this lesson teaches

The idea

Teams test in the language they already use. The checks from your eval harness do not depend on Python.

Why a tester cares

Porting them to Java or JavaScript shows the method is what matters: read the cases, call the API, apply the patterns, one test per case.

Words you will meet

JUnit and REST Assured:
the usual Java tools for tests and API calls.
Playwright Test:
Playwright's JavaScript test runner, which can call APIs without a browser.
Parameterized test:
one test run once per row of data.

What you will do

  1. 1Pick a language
  2. 2One test per case
  3. 3Apply both patterns
  4. 4Submit
Jump to practice

Teams test in the language they already use. The checks from lesson 15 do not depend on Python: read the cases, call the endpoint, apply the patterns, one test per case. This lesson ports them.

  • Java: JUnit 5 with REST Assured. @ParameterizedTest with @MethodSource turns each line of cases.jsonl into its own test.
  • JavaScript: Playwright Test's request fixture calls the API without a browser. A for loop around test() makes one test per case.

The runner sets OPENAI_BASE_URL and OPENAI_API_KEY for both, and reads the JUnit XML report either way.

Your task

Pick a language and run every case, applying must_not_match when a case has one. On submit your tests run against a correct bot and faulty ones, then with a larger cases file that includes harder cases.

Sign in to practise

The lesson is free to read. A free account lets you talk to the practice bots, run your code and save your score. You will come back to this lesson.

1

Your code

Write it in
Both are graded the same way.
against RefundBot

How this is checked: When you submit, your tests run against 6 versions of RefundBot: 2 correct and 4 with a planted fault. Good tests pass on every correct version and fail on every faulty one. Run tries them on the practice copy first; the result table shows each version.

Core checks earn 50 points and the harder checks the other 50. You can submit as many times as you like.

About this lesson

LLM API tests in Java REST Assured or Playwright JavaScript, one test per case from JSONL

AI Testing for QA EngineersAdvancedFrameworks and other languages

How it works

Teams test in the language they already use, and the checks from the eval harness do not depend on Python. Read the cases, call the endpoint, apply the patterns, and make one test per case.

In Java, JUnit 5 with REST Assured does the job: a parameterized test with a method source turns each line of the case file into a test. In JavaScript, Playwright Test's request fixture calls the API without a browser, and a loop around test definitions makes one test per case. Either way the runner reads the JUnit XML report.

About the assignment

Pick Java or JavaScript, run every case from the file, and apply must-not-match when a case has one, so the tests catch faulty builds and harder cases without false alarms.

What you will do

  1. Read the case file when the tests run.
  2. Create one test per case, named by its ID.
  3. Apply both patterns, case-insensitively, with messages that show the reply.

Common mistakes

  • A hard-coded case list

    Grading uses a larger case file. Read it at run time.

  • Skipping must-not-match

    Harder cases rely on it to catch replies that mention the right number beside a wrong one.

In a real test suite

Porting a harness is also a good review of it: every check you cannot explain clearly enough to rewrite in another language is a check worth simplifying.

Keeping the case file shared between languages means product and support staff can add cases once and every team's suite picks them up.