Allow test fixtures and test methods to throw errors by default.

* test/testcase.vala (TestCase): Add a generic throws clause to both
  TestMethod and set_up and tear_down, update subclasses.
This commit is contained in:
Michael James Gratton 2018-03-07 17:30:14 +11:00
parent 6b24e07e56
commit 50f73ff252
27 changed files with 168 additions and 155 deletions

View file

@ -16,13 +16,13 @@ class Geary.TimeoutManagerTest : Gee.TestCase {
base("Geary.TimeoutManagerTest");
add_test("start_reset", start_reset);
if (Test.slow()) {
add_test("test_seconds", test_seconds);
add_test("test_milliseconds", test_milliseconds);
add_test("test_repeat_forever", test_repeat_forever);
add_test("seconds", seconds);
add_test("milliseconds", milliseconds);
add_test("repeat_forever", repeat_forever);
}
}
public void start_reset() {
public void start_reset() throws Error {
TimeoutManager test = new TimeoutManager.seconds(1, () => { /* noop */ });
assert(!test.is_running);
test.start();
@ -31,7 +31,7 @@ class Geary.TimeoutManagerTest : Gee.TestCase {
assert(!test.is_running);
}
public void test_seconds() {
public void seconds() throws Error {
Timer timer = new Timer();
TimeoutManager test = new TimeoutManager.seconds(1, () => { timer.stop(); });
@ -45,7 +45,7 @@ class Geary.TimeoutManagerTest : Gee.TestCase {
assert_epsilon(timer.elapsed(), 1.0, SECONDS_EPSILON);
}
public void test_milliseconds() {
public void milliseconds() throws Error {
Timer timer = new Timer();
TimeoutManager test = new TimeoutManager.milliseconds(100, () => { timer.stop(); });
@ -59,7 +59,7 @@ class Geary.TimeoutManagerTest : Gee.TestCase {
assert_epsilon(timer.elapsed(), 0.1, MILLISECONDS_EPSILON);
}
public void test_repeat_forever() {
public void repeat_forever() throws Error {
Timer timer = new Timer();
int count = 0;