Test
S'ensenya a
Entorns de desenvolupamentVerificació i optimització de programariDAW
Setup and teardown APIs
To make testing easier, you can use these APIs to help perform setup and teardown for test cases:
Deno.test.beforeAllDeno.test.beforeEachDeno.test.afterAllDeno.test.afterEach
Here’s a concrete example showing how to set up a test database:
;
;
;
// Run once before all tests
testDb = new ":memory:";
`CREATE TABLE users (
id INTEGER PRIMARY KEY, name TEXT NOT NULL, email TEXT UNIQUE
);
`);
});
// Run before each individual test
"DELETE FROM users";
"INSERT INTO users (name, email) VALUES (?, ?)",
);
"Alice", "alice@example.com";
"Bob", "bob@example.com";
});
// Run after each individual test
// Clean up test data
"DELETE FROM users";
});
// Run once after all tests
;
});
"should find user by email", ;
;
user?.name, "Alice";
});
"should create new user", "INSERT INTO users (name, email) VALUES (?, ?)",
);
"Charlie", "charlie@example.com";
;
;
result!.count, 3; // 2 from beforeEach + 1 new
});Estàs llegint una vista prèvia.
Inicia sessió amb Google per llegir la pàgina completa.
Inicia sessió amb GoogleAmb qualsevol compte de Google. Només et demanarem que acceptis les condicions del servei.