Skip to content

Commit

Permalink
Add coverage collection to tests (#131)
Browse files Browse the repository at this point in the history
  • Loading branch information
sea-bass authored Aug 6, 2023
1 parent 532208c commit 8ff8f83
Show file tree
Hide file tree
Showing 8 changed files with 14 additions and 77 deletions.
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

0 comments on commit 8ff8f83

Please sign in to comment.