Skip to content

Test Model Configuration

packageTeardown()

packageTeardown() — returns any

Available in: test Category: Callback Functions

The packageTeardown() function is a callback in Wheels’ legacy testing framework. It runs once after the last test case in the test package. Use it to perform cleanup tasks that are shared across all tests in the package, such as deleting test records, resetting application state, or clearing cached data.

component extends="app.tests.Test" {

    function packageSetup() {
        // Run once before any test in this package
        model("user").new(username="testuser", email="test@example.com").save();
    }

    function packageTeardown() {
        // Run once after all tests in this package

        // Delete test user
        var user = model("user").findOneByUsername("testuser");
        if (user) {
            user.delete();
        }

        // Clear test configuration
        structClear(application.testConfig);
    }

    function test_User_Exists() {
        var user = model("user").findOneByUsername("testuser");
        assert("user eq true");
    }
}