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 8 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 06764cf..6d46d31. 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

All modified and coverable lines are covered by tests ✅

Project coverage is 0.00%. Comparing base (06764cf) to head (6d46d31).

✅ All tests successful. No failed tests found.

Additional details and impacted files
@@              Coverage Diff               @@
##           development   #363       +/-   ##
==============================================
- Coverage        23.17%      0   -23.18%     
==============================================
  Files               60      0       -60     
  Lines             5342      0     -5342     
  Branches          2329      0     -2329     
==============================================
- Hits              1238      0     -1238     
+ Misses            4088      0     -4088     
+ Partials            16      0       -16     

see 60 files with indirect coverage changes

Components Coverage Δ
algorithms ∅ <ø> (∅)
drivers ∅ <ø> (∅)
handlers ∅ <ø> (∅)
interfaces ∅ <ø> (∅)
states ∅ <ø> (∅)
util ∅ <ø> (∅)
vision ∅ <ø> (∅)
src ∅ <ø> (∅)

@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