Arc Forumnew | comments | leaders | submitlogin
Unit-test.arc now gives reproduction code of failing tests
3 points by zck 1662 days ago | 2 comments
I realized something. If macros take as input the unevaluated source code, a macro can print out the unevaluated source code.

So I made that happen. When a test fails, the user is given code to reproduce the test, including setup and teardown code.

An example (indented differently to be more readable)

  arc> (suite math (setup x 3) (test adding (assert-same 5 (+ 1 x))))
  math:  	1 test,  	0 nested suites.
  'nil
  
  arc> (test math)
  Suite math:
  math.adding failed: (+ 1 x) should be 5 but instead was 4.
      rerun this test: (withs (x 3) (do1 (do (assert-same 5 (+ 1 x)))))
  In suite math, 0 of 1 tests passed.
  
  Test run completed in 0 seconds.
  Oh dear, 1 of 1 failed.
  '(0 1)
Not fully documented in the readme yet. I'll get to it.


2 points by akkartik 1661 days ago | link

This is awesome. Particularly the instructions for rerunning a single test in isolation.

-----

2 points by zck 1661 days ago | link

Thanks! The goal is to make it _way_ easier to reproduce a single test, and investigate what's going wrong.

And it's a testament to the power of Lisp that I didn't have to change much to make it happen.

-----