Test Model Configuration
packageTeardown()
Signature
Section titled “Signature”packageTeardown() — returns any
Available in: test
Category: Callback Functions
Description
Section titled “Description”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.
Examples
Section titled “Examples”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");
}
}