Photo by Priscilla Du Preez πŸ‡¨πŸ‡¦ / Unsplash

Exercise: Custom Asserts

Exercises Oct 29, 2025 (Oct 29, 2025) Loading...

coming... for Workroom PlayTime 036

We'll use LLMs to help us build custom asserts. You'll use your own access to an LLM, and we'll work in instances of a pre-set-up Github Codespace environment with a JavaScript test harness, a Python test harness, and code which could do with a custom assert or two.

We'll look at the tiny systems, identify what would help, ask LLMs to build working asserts, see what they give back, and compare notes.

Also to come: a page on custom asserts

Environment

I've built something that has all the code, test harnesses and plumbing for you to try this in JavaScript and Python. You'll access your own copy of that environment via VisualStudio Code in your browser.

For these exercises, we'll try out Github Codespaces. You may need a github acount.

Go to the Custom Asserts repo , and you should see a readme page – click on the "open in Github Codespaces" button and wait. Further instructions are in the readme – once you're in, you'll need to run something on the commandline to install all the infrastructure dependencies, and more to run tests. You can browse the software under test while the dependencies are being installed.

As of today (29 Oct), the environment is working, with one JS example. I'm building out a second, and Python equivalents of both. It'll be done by the workshop.

Infrastructure

The tests for my JavaScript examples here use Chai (assertion library) and Mocha (unit test framework). My Python examples use bare Python and pyTest (unit test framework). 

You'll need to go to your own LLM to ask for code – you'll find examples below.

Python and assertion libraries

Assertion libraries seem not as prevalent in the Python community as Chai and others are in the JS community.

Perhaps that is because it is simple and common to build custom asserts directly in Python. Pytest leans heavily on Python’s own assert and has a hook pytest_assertrepr_compare for detailed messages.

Python does have assertion libraries – pyHamcrest being the standout example.

Exercise 1 – checking a record

Examples of generated test code

Exercise 2 – checking a distribution

Examples of generated test code

Member reactions

Reactions are loading...

Sign in to leave reactions on posts

Tags

Comments

Sign in or become a Workroom Productions member to read and leave comments.

James Lyndsay

Getting better at software testing. Singing in Bulgarian. Staying in. Going out. Listening. Talking. Writing. Making.

Great! You've successfully subscribed.
Great! Next, complete checkout for full access.
Welcome back! You've successfully signed in.
Success! Your account is fully activated, you now have access to all content.