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

Add coverage collection to tests #131

Merged
merged 1 commit into from
Aug 6, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ docs/build/
docs/source/generated

# Test artifacts
**/.coverage
test/results/

# Temporary folders generated by PDDLStream
Expand Down
1 change: 1 addition & 0 deletions pyrobosim_ros/package.xml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
<test_depend>ament_flake8</test_depend>
<test_depend>ament_pep257</test_depend>
<test_depend>python3-pytest</test_depend>
<test_depend>python3-pytest-cov</test_depend>

<export>
<build_type>ament_cmake</build_type>
Expand Down
4 changes: 3 additions & 1 deletion pyrobosim_ros/test/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
# CMakeLists.txt for pyrobosim_ros tests

find_package(ament_cmake_pytest REQUIRED)

set(AMENT_CMAKE_PYTEST_WITH_COVERAGE ON)

set(_pytest_tests
test_ros_conversions.py
)
Expand Down
24 changes: 0 additions & 24 deletions test/disabled_test_copyright.py

This file was deleted.

26 changes: 0 additions & 26 deletions test/disabled_test_flake8.py

This file was deleted.

24 changes: 0 additions & 24 deletions test/disabled_test_pep257.py

This file was deleted.

1 change: 1 addition & 0 deletions test/python_test_requirements.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
lark
py!=1.10.0
pytest
pytest-cov
pytest-dependency
pytest-html
10 changes: 8 additions & 2 deletions test/run_tests.bash
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,12 @@ TEST_RESULTS_DIR="${SCRIPT_DIR}/results"
# Run regular pytest tests
echo "Running Python package unit tests..."
python3 -m pytest "$SCRIPT_DIR" \
--cov="$SCRIPT_DIR" --cov-branch --cov-report term \
--cov-report html:"$TEST_RESULTS_DIR/test_results_coverage_html" \
--cov-report xml:"$TEST_RESULTS_DIR/test_results_coverage.xml" \
--junitxml="$TEST_RESULTS_DIR/test_results.xml" \
--html="$TEST_RESULTS_DIR/test_results.html" --self-contained-html
--html="$TEST_RESULTS_DIR/test_results.html" \
--self-contained-html

echo ""

Expand All @@ -26,7 +30,9 @@ then
WORKSPACE_DIR="${COLCON_PREFIX_PATH}/../"
echo "Running ROS package unit tests from ${WORKSPACE_DIR}..."
pushd "${WORKSPACE_DIR}" > /dev/null || exit
colcon test --event-handlers console_cohesion+
colcon test \
--event-handlers console_cohesion+ \
--pytest-with-coverage --pytest-args " --cov-report term"
colcon test-result --verbose
popd > /dev/null || exit
fi