UTSA-ARC / AeroRunner

Arduino-based Flight Computer program
MIT License
0 stars 0 forks source link

An Example Test on `Check_Systems()` #91

Closed eliteabhi closed 4 months ago

eliteabhi commented 4 months ago

wooo....this is gonna be a lot...


TL;DR ~ I made an example test for how to generally go about unit testing

I also had to change...a lot


I might repeat a lot of things that I PRd already but I'm very forgetful so bare with me

Implimentation

There are a couple of new files that have been added

toolchain.h -

This is for compiler-specific imports and variable declarations I had to implement this because the Unity testing framework runs on native ( for how we're using it ) This file basically just handles the import compatibility between the Arduino based code and native

lib/elapsedMillis.h -

This is because there is no elapsedMillis library for the native toolchain It is just a compatible version of the Arduino equivalent, which works because we're using ArduinoFake with the native toolchain

testing_globals.h -

This is a global file that imports and defines elements that are commonly used among all the tests I also included some helpful functions to make life a little easier ;)

test_example.h -

This is the header for the test_example_health_check.cpp file It defines a couple things: the imports, test cases, and test case dependencies (I.E. params for test cases)

test_example_health_check.cpp -

This is where the test cases are initialized, as well as their helper functions

Extra Notes:

  1. I tried to document everything I did in the tests as well as concisely name my definitions
  2. I did have to re-write a lot of the pre-existing code to integrate the toolchain changes, any pre-existing code should work the same as before
  3. In order to run the tests you have to change your environment to env:testing
  4. The default environment is env:teensy-release but I suggest using env:teensy-debug when building UNLESS you're PRing to a release/ branch

 Mention [stepsize] in a comment if you'd like to report some technical debt. See examples here.

eliteabhi commented 4 months ago

Looks good, I think I understood the testing example, will let you know if I have any questions.

Also noticed this: functions.h 133-135: should it be r_accel[0] for all three? or r_accel[0], r_accel[1], r_accel[2]?

sigh....yes it's supposed to be that...

Thanks for pointing it out lol

eliteabhi commented 4 months ago

Looks good, I think I understood the testing example, will let you know if I have any questions.

Also noticed this: functions.h 133-135: should it be r_accel[0] for all three? or r_accel[0], r_accel[1], r_accel[2]?

sigh....yes it's supposed to be that...

Thanks for pointing it out lol

I'll fix it and re-merge