New lightweight pure‑T‑SQL unit‑testing framework (T‑TEST) — feedback welcome

  •  

    Hi all,

    I’ve just open‑sourced T‑TEST, a tiny alternative to tSQLt that lives 100 % in T‑SQL—no CLR, no extra binaries.

    Why you might care

    • one install.sql, < 10 KB of objects
    • every proc in the tests schema is a test (auto‑discover by name convention)
    • inline assertion functions (not SPs!) (test.assert_equals, test.fail, …)
    • one-row recordset assertion (using FOR JSON PATH)
    • try-catch sentinel‑style exceptions testing

    30‑second quick‑start

    :r install.sql          -- run once per database
    CREATE OR ALTER PROCEDURE tests.[dbo.sample@happy_path]
    AS

    SELECT test.assert_equals('1+1 must be 2',
    2,
    (SELECT 1+1)
    );
    GO
    EXEC test.run;

    Sample output:

    INFO: 1 tests executed. Succeeded: 1, failed: 0

    Repo (docs, full comparison with tSQLt):

    https://github.com/uratol/t-test

    Real‑world demo (50+ tests in action):

    https://github.com/uratol/t-chess

    I’d love your thoughts—bugs, ideas, “this saved me five minutes”, anything.

    Thanks!

    (Disclaimer: I’m the author.)

    • This topic was modified 3 weeks, 3 days ago by uratol.
  • Interesting. I'll give it a look when I get a chance.

    If you would like t write a tutorial or article, send me a note.

  • Very nice.  The chess app is interesting too.  Could you explain the project structure of the chess app a little more?  There appears to be more than one chess engine

    Aus dem Paradies, das Cantor uns geschaffen, soll uns niemand vertreiben können

  • I've expanded the description of the engines https://github.com/uratol/t-chess/blob/master/README.md .

    The chess project is more as a tutorial demo and for fun, it plays terribly actually, SQL is very slow for such tasks.

    Among the interesting things I can still point out:

    • Generation of stored procedures by template - since natively-compiled procedures do not support recursion, I had to simulate it by creating several copies of the procedure (sp_1, sp_2, ...). And for this purpose, I had to develop the templates mechanism. More details can be found in [template].[generate_object].
    • The engine call (polymorphism realization) is done not by dynamic SQL, but by a pattern:
    declare @my_var nvarchar(128) = 'engine_myengine.make_move'
    exec @my_var ...

Viewing 4 posts - 1 through 4 (of 4 total)

You must be logged in to reply to this topic. Login to reply