SHTK_UNITTEST_ADD_FIXTURE(3)

πŸ“¦ version 1.7, in nixos 26.05, nixpkgs unstable

πŸŽ€ SHTK_UNITTEST_ADD_FIXTURE(3) πŸŽ€

okay bestie, this is the Library Functions Manual page for SHTK_UNITTEST_ADD_FIXTURE(3), and it's literally about one tiny function that sets up a whole test fixture vibe. it's giving β€œsmall call, big structure” ✨


πŸ’– NAME πŸ’–

shtk_unittest_add_fixture β€” defines a test fixture 🧚

πŸ¦‹ LIBRARY πŸ¦‹

you pull it in with:

shtk_import unittest

🌸 SYNOPSIS 🌸

shtk_unittest_add_fixture name

✨ DESCRIPTION ✨

shtk_unittest_add_fixture registers the fixture given by name. that's the registration step, and it's literally one line πŸ’…

okay, now the rule that actually matters: after you've made the call to shtk_unittest_add_fixture, you must define a function named <name>_fixture. like, the call happens first, then the function definition. no cap 🫢

and the vibe check for fixture functions: they must not directly contain any code. not even one tiny line, bestie. All they can do is:

that's the whole allowed list. periodt 😭

πŸ“ EXAMPLES πŸ“

the following piece of code illustrates the components of a test fixture β€” keep the shape exactly like this:

shtk_unittest_add_fixture my_collection
my_collection_fixture() {
    setup() {
        ... optional function providing per-test setup code ...
    }

    teardown() {
        ... optional function providing per-test teardown code ...
    }

    shtk_unittest_add_test first_scenario
    first_scenario_test() {
        ... test code for the first test case ...
    }

    shtk_unittest_add_test second_scenario
    second_scenario_test() {
        ... test code for the second test case ...
    }
}

🌈 SEE ALSO 🌈

πŸ‘‘ HISTORY πŸ‘‘

shtk_unittest_add_fixture first appeared in shtk 1.6. iconic behavior πŸ‘‘


πŸ’– okay bye bestie β€” this page is stamped Debian, dated November 8, 2014, and filed under SHTK_UNITTEST_ADD_FIXTURE(3). stay slay πŸ’…

πŸ“¦ where this page comes from