Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unit Test Implementation #363

Draft
wants to merge 5 commits into
base: development
Choose a base branch
from
Draft

Conversation

targed
Copy link
Contributor

@targed targed commented Jan 9, 2025

Description

This is an enhancement of the unit tests for the multimedia board and the navigationbord. I am merging this as we have updates to the methods that our codebase uses for testing. I was not able to finish the driveboard tests, so just ignore that for right now, I am working on it.

Changes Made

NavigationBoard.cc

  • Created a mock NavBoard testing class to use with the unit tests.
  • Changed all the unit test to TEST_F because you can't use TEST and TEST_F in the same file, and you need to use TEST_F to use the mock class inside the test.
  • Added a unit test to verify the navboard initializes its constructors correctly.
  • Added a unit test to test that the GPS returns the correct values. (Based on Rolla, MO)
  • Added a unit test to test that the navboard returns the correct UTM data. (Based on Rolla, MO)

MultimediaBoard.cc

  • Created a mock MultimediaBoard testing class to use with the unit tests.
  • Changed all the unit test to TEST_F because you can't use TEST and TEST_F in the same file, and you need to use TEST_F to use the mock class inside the test.
  • Added a unit test to verify the MultimediaBoard initializes its constructors correctly.
  • Added a unit test to test that the lighting state is set correctly.
  • Added a unit test to test that the RGB values are set correctly

How It Works

NavigationBoard.cc

  • The mock NavBoard testing class creates a new NavBoard object that is under the gtest testing framework. It allows us to use it in each unit test in the file (as long as it is using TEST_F) so we don't have to create and delete a NavBoard each time we want to test something.
  • ConstructorInitializesMembers: This test ensures that the NavigationBoard constructor initializes all member variables correctly. This is important to verify that the object starts in a valid state.
  • GetGPSDataReturnsCorrectData: This test checks that the GetGPSData method returns the correct GPS data. This is based on a known location (Rolla, MO) to ensure the method's accuracy.
  • GetUTMDataReturnsCorrectData: This test verifies that the GetUTMData method returns the correct UTM data. This is based on a known location (Rolla, MO) to ensure the method's accuracy.

MultimediaBoard.cc

  • The mock MultimediaBoardTest class creates a new MultimediaBoard object that is under the gtest testing framework. It allows us to use it in each unit test in the file (as long as it is using TEST_F so we don't have to create and delete a MultimediaBoard each time we want to test something.
  • ConstructorInitializesCorrectly: This test ensures that the MultimediaBoard constructor initializes the lighting state and RGB values correctly. This is important to verify that the object starts in a valid state.
  • SendLightingStateSetsStateCorrectly: This test checks that the SendLightingState method correctly sets the lighting state. This ensures that the method functions as expected and modifies the internal state appropriately.
  • SendRGBSetsRGBValuesCorrectly: This test verifies that the SendRGB method correctly sets the RGB values. This ensures that the method functions as expected and modifies the internal state appropriately.

Testing

  • Tested on Linux
  • Unit tests covering NavigationBoard and MultimediaBoard
  • Integration tests covering the initialization and functionality of NavigationBoard and MultimediaBoard
  • Manual tests performed to ensure no memory leaks and correct initialization of objects

Screenshots/Video (if applicable)

N/A

Performance Improvements (if applicable)

N/A

Documentation Updates (if applicable)

N/A

Known Issues (if applicable)

DriveBoard tests are not yet completed and are not included in this PR.

Additional Context

N/A

@targed targed requested a review from a team as a code owner January 9, 2025 08:42
Copy link

deepsource-io bot commented Jan 9, 2025

Here's the code health analysis summary for commits d4946d5..5481a9c. View details on DeepSource ↗.

Analysis Summary

AnalyzerStatusSummaryLink
DeepSource Shell LogoShell✅ SuccessView Check ↗
DeepSource Secrets LogoSecrets✅ SuccessView Check ↗
DeepSource Python LogoPython✅ SuccessView Check ↗
DeepSource Docker LogoDocker✅ SuccessView Check ↗
DeepSource C & C++ LogoC & C++✅ SuccessView Check ↗

💡 If you’re a repository administrator, you can configure the quality gates from the settings.

Copy link

codecov bot commented Jan 9, 2025

Codecov Report

Attention: Patch coverage is 51.64835% with 44 lines in your changes missing coverage. Please review.

Project coverage is 25.35%. Comparing base (d4946d5) to head (5481a9c).

✅ All tests successful. No failed tests found.

Files with missing lines Patch % Lines
tests/Unit/src/drivers/NavigationBoard.cc 39.62% 0 Missing and 32 partials ⚠️
tests/Unit/src/drivers/MultimediaBoard.cc 68.42% 0 Missing and 12 partials ⚠️
Additional details and impacted files
@@               Coverage Diff               @@
##           development     #363      +/-   ##
===============================================
+ Coverage        24.29%   25.35%   +1.05%     
===============================================
  Files               80       79       -1     
  Lines             6371     6440      +69     
  Branches          2846     2892      +46     
===============================================
+ Hits              1548     1633      +85     
+ Misses            4571     4508      -63     
- Partials           252      299      +47     
Files with missing lines Coverage Δ
tests/Unit/src/drivers/MultimediaBoard.cc 69.23% <68.42%> (-19.66%) ⬇️
tests/Unit/src/drivers/NavigationBoard.cc 40.74% <39.62%> (-48.15%) ⬇️

... and 4 files with indirect coverage changes

Components Coverage Δ
algorithms 59.11% <ø> (ø)
drivers 42.05% <ø> (+18.47%) ⬆️
handlers 0.00% <ø> (ø)
interfaces 26.46% <ø> (ø)
states 0.00% <ø> (ø)
util 32.91% <ø> (ø)
vision 13.86% <ø> (ø)
src 43.57% <ø> (ø)

@Byrdman32 Byrdman32 marked this pull request as draft January 9, 2025 18:03
@Byrdman32 Byrdman32 changed the title Topic/unit tests enhancement Unit Test Implementation Jan 9, 2025
@Byrdman32 Byrdman32 added 3-Star Indicates a moderate level of difficulty, requiring a good understanding of the topic or task. enhancement Requests for new features or improvements to existing features. testing Tasks related to creating or improving tests, including unit and integration tests. labels Jan 10, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
3-Star Indicates a moderate level of difficulty, requiring a good understanding of the topic or task. enhancement Requests for new features or improvements to existing features. testing Tasks related to creating or improving tests, including unit and integration tests.
Projects
Status: In Development
Development

Successfully merging this pull request may close these issues.

2 participants