Skip to content

Commit

Permalink
Dependency Unity for testing should not be part of build dependencies…
Browse files Browse the repository at this point in the history
…, unity_config.h can be removed and Test items are correctly referenced.
  • Loading branch information
psmgeelen committed Dec 29, 2023
1 parent 54b8e58 commit 0f8ea31
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 251 deletions.
1 change: 0 additions & 1 deletion controller/tea_poor/platformio.ini
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,5 @@ framework = arduino
test_framework = unity
lib_deps =
lasselukkari/aWOT@^3.5.0
throwtheswitch/Unity@^2.5.2
test_ignore = local

12 changes: 6 additions & 6 deletions controller/tea_poor/test/test_local/WaterPumpScheduler_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,17 +37,17 @@ void test_pump_stops_after_given_time() {
waterPumpScheduler.start(runTimeMs, currentTimeMs);
// check status
auto status = waterPumpScheduler.status();
UNITY_TEST_ASSERT_TRUE(status.isRunning);
UNITY_TEST_ASSERT_EQUAL(status.stopTime, runTimeMs);
TEST_ASSERT_TRUE(status.isRunning);
TEST_ASSERT_EQUAL(status.stopTime, runTimeMs);

while (currentTimeMs < runTimeMs) {
waterPumpScheduler.tick(currentTimeMs);
UNITY_TEST_ASSERT_TRUE(fakeWaterPump.isRunning());
TEST_ASSERT_TRUE(fakeWaterPump.isRunning());
currentTimeMs += 100;
}
// pump should be stopped after given time
waterPumpScheduler.tick(runTimeMs + 1);
UNITY_TEST_ASSERT_FALSE(fakeWaterPump.isRunning());
TEST_ASSERT_FALSE(fakeWaterPump.isRunning());
}

// test that pump is periodically forced to stop after given time
Expand All @@ -60,14 +60,14 @@ void test_pump_is_periodically_forced_to_stop_after_given_time () {
waterPumpScheduler.start(1, currentTimeMs);
currentTimeMs += 1;
waterPumpScheduler.tick(currentTimeMs);
UNITY_TEST_ASSERT_FALSE(fakeWaterPump.isRunning()); // pump should be stopped after given time
TEST_ASSERT_FALSE(fakeWaterPump.isRunning()); // pump should be stopped after given time

for(int i = 0; i < 10; i++) {
// emulate that pump was started again
fakeWaterPump.start();
currentTimeMs += 1000;
waterPumpScheduler.tick(currentTimeMs);
UNITY_TEST_ASSERT_FALSE(fakeWaterPump.isRunning()); // pump should be stopped
TEST_ASSERT_FALSE(fakeWaterPump.isRunning()); // pump should be stopped
}
}

Expand Down
244 changes: 0 additions & 244 deletions controller/tea_poor/test/test_local/unity_config.h

This file was deleted.

0 comments on commit 0f8ea31

Please sign in to comment.