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

Test for Optical Flow checks correct camera position #23266

Open
wants to merge 8 commits into
base: main
Choose a base branch
from

Conversation

PavloZMN
Copy link

Solved Problem

OpticalFlow tests coverage improved with additional tests.

Fixes #{Github issue ID}

Solution

New test 'VehicleOpticalFlowTest' which checks camera orientation for Optical Flow.

Changelog Entry

For release notes:

New test 'VehicleOpticalFlowTest' which checks camera orientation for Optical Flow.

Test coverage

VehicleOpticalFlowTest - new test



TEST_F(VehicleOpticalFlowTest, whenCameraDownFacing_ThenSensorSelected)
{
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can you add some comments to the test methods? Usually best practice is to structure it with
// GIVEN
...
// WHEN <>
...
// THEN
EXPECT...

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Test name contains "WHEN" and "THEN" section:
whenCameraDownFacing_ThenSensorSelected
With such approach, comments are unnecessary.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @sfuhrer , can you please take a look on my latest answer?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @PavloZMN , please do not mix different naming styles. We usually use the MixedCase for the test name. So here e.g. CameraFacingDown.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I still think adding some simple //GIVEN, //WHEN, //THEN comments increase the readability of the code and don't find them unnecessary. It's a pattern that we establish for all unit tests and makes it very easy to understand the aim of a test without having to read actual code.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @sfuhrer, testcase name was changed, and //GIVEN, //WHEN, //THEN comments were added, please take a look.

…owTest.cpp

Co-authored-by: Mathieu Bresciani <brescianimathieu@gmail.com>


TEST_F(VehicleOpticalFlowTest, whenCameraDownFacing_ThenSensorSelected)
{
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @PavloZMN , please do not mix different naming styles. We usually use the MixedCase for the test name. So here e.g. CameraFacingDown.



TEST_F(VehicleOpticalFlowTest, whenCameraDownFacing_ThenSensorSelected)
{
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I still think adding some simple //GIVEN, //WHEN, //THEN comments increase the readability of the code and don't find them unnecessary. It's a pattern that we establish for all unit tests and makes it very easy to understand the aim of a test without having to read actual code.

TEST_F(VehicleOpticalFlowTest, whenCameraDownFacing_ThenSensorSelected)
{
distance_sensor_s message = createDistanceSensorMessage(distance_sensor_s::ROTATION_DOWNWARD_FACING);
orb_advertise(ORB_ID(distance_sensor), &message);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You're missing the .publish step no? Have a look here:

orb_publish(ORB_ID(distance_sensor), distance_sensor_pub, &message);

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For this functionality orb_advertise is enough, please take a look on VehicleOpticalFlow::UpdateDistanceSensor().

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also testcase name was changed, and //GIVEN, //WHEN, //THEN comments added

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants