8.3K Views
November 30, 22
スライド概要
ソフトウェアの品質向上にテストは欠かせません。
ROS2を使った開発を進めるにあたり、テスト工程を見据えて、ROS公式ドキュメントを参照します。
しかし、ROS公式の解説では、テストに関する記述が少なく、そもそもどういったテストが可能なのか、という疑問が生じます。
また、ROS公式の解説で実行可能なサンプルがほとんどなく、公式で動作確認されている記述方法がわからないという問題もあります。
そこで、本セミナーでは、ROS2 で使えるテストフレームワークの解説と、実践サンプルの紹介を行います。
<過去資料>
・ROS2自律走行実現に向けて 1 : https://www.docswell.com/s/fixstars/57VGDN-20221017
・ROS2自律走行実現に向けて 2: https://www.docswell.com/s/fixstars/K8G1N9-20221130
・Jetson活用 ROS2自律走行実現に向けて ~自律移動ロボット用ー自己位置推定のCUDA高速化: https://www.docswell.com/s/fixstars/KQ814X-20211104
・フィックスターズの自動車向けソフトウェア開発: https://at.fixstars.com/ja
フィックスターズは、コンピュータの性能を最大限に引き出すソフトウェア開発のスペシャリストです。車載、産業機器、金融、医療など、幅広い分野での開発経験があります。また、ディープラーニングや機械学習などの最先端技術にも力を入れています。 並列化や最適化技術を駆使して、マルチコアCPU、GPU、FPGA、量子アニーリングマシンなど、さまざまなハードウェアでソフトウェアを高速化するサービスを提供しています。さらに、長年の経験から培ったハードウェアの知識と最適化ノウハウを活かし、高精度で高性能なアルゴリズムの開発も行っています。 ・開催セミナー一覧:https://www.fixstars.com/ja/seminar ・技術ブログ :https://proc-cpuinfo.fixstars.com/
ROS2自律走行実現に向けて 次世代ロボット開発フレームワーク ROS2のテストフレームワーク徹底理解 Copyright © Fixstars Group
本日のAgenda ⚫ はじめに ⚫ フィックスターズのご紹介 ⚫ テストの必要性 ⚫ ROS2で可能なテスト/lint ⚫ サンプルアプリでのテスト実装 ⚫ その他 TIPS Copyright © Fixstars Group 2
はじめに Copyright © Fixstars Group
本セミナーの位置づけ ⚫ ウェビナー「ROS2自律走行実現に向けて」シリーズでは、 自律走行する車両型ロボットの実現に向け、 ROS2を使った開発に関連する、様々な情報を発信しています ⚫ vol.1(発表資料) ROS1上で開発した資産の活用 ○ 自己位置推定パッケージの CUDA高速化 vol.2(発表資料) ○ パッケージ開発に欠かせないビルドシステムの解説 今回の内容 ○ 品質向上に欠かせないテストフレームワークの解説 ○ ⚫ ⚫ ⚫ こんな方に向いています ○ ROS2 の開発をしたことがあり、ソフトウェアの品質を向上させたいとお考えの方 Copyright © Fixstars Group 4
発表者紹介 冨田 明彦 青木 修平 ソリューションカンパニー 執行役員 ソリューション第3事業部 シニアエンジニア 2008年に入社。金融、医療業界において、ソ フトウェア高速化業務に携わる。その後、新規 事業企画、半導体業界の事業を担当し、現職。 2018年に入社。主に ADAS 向けの画像処理ア ルゴリズムの開発や高速化、シミュレーション 環境構築を担当。 Copyright © Fixstars Group 5
フィックスターズの ご紹介 Copyright © Fixstars Group
フィックスターズの強み コンピュータの性能を最大限に引き出す、ソフトウェア高速化のエキスパート集団 ハードウェアの知見 アルゴリズム実装力 各産業・研究分野の知見 目的の製品に最適なハードウェアを見抜き、 その性能をフル活用するソフトウェアを開 発します。 ハードウェアの特徴と製品要求仕様に合わ せて、アルゴリズムを改良して高速化を実 現します。 開発したい製品に使える技術を見抜き、実 際に動作する実装までトータルにサポート します。 Copyright © Fixstars Group 7
サービス提供分野 半導体 産業機器 金融 自動車 ● NAND型フラッシュメモリ向けフ ァームウェア開発 ● 次世代AIチップの開発環境基盤 生命科学 ● Smart Factory実現への支援 ● マシンビジョンシステムの高速化 ● 自動運転の高性能化、実用化 ● ゲノム解析の高速化 ● 次世代パーソナルモビリティの 研究開発 ● 医用画像処理の高速化 Copyright © Fixstars Group ● デリバティブシステムの高速化 ● HFT(アルゴリズムトレード)の高速化 ● AI画像診断システムの研究開発 8
自動車向けソフトウェア開発 アルゴリズム開発から量産車ターゲット向けの高速化まで、 自動運転の実現に向けた統合的な技術開発を行っています。 ご支援内容 Copyright © Fixstars Group 9
組込み高速化 組込み機器製品の計算処理実装をお手伝いしています。 お客様の課題 ご支援内容 組込みシステムの目標性能が達成できない ターゲットデバイスの特性に合わせて、 性能要求を満たしたい 安価なハードウェアでも処理速度を維持し 製品にかかるコストを下げたい ターゲットデバイスの例 ARM/ TOSHIBA Visconti/ Renesas R-Car/ NXP S32/ Automotive Platform/ CEVA-XM6/ Texas Instruments © Fixstars Group C6000/ Cadence Vision DSP FamilyCopyright など 最適化方針のご提案 ボトルネック調査、最適化に向けた検討 システム設計コンサルティング ハードウェア選定を含めたシステム設計のご提案 アルゴリズムの改善と移植 既存アルゴリズムを改善して計算を高速化 組込みアルゴリズム開発 ターゲットデバイス向けに最適化されたアルゴリズムを実装 10
サービス領域一覧 様々な領域でソフトウェア高速化サービスを提供しています。大量データの高速処理は、 お客様の製品競争力の源泉となっています。 組込み高速化 GPU向け高速化 AI・深層学習 画像処理・アルゴリズム 開発 FPGAを活用した システム開発 分散並列システム開発 量子コンピューティング 自動車向け フラッシュメモリ向けフ ソフトウェア開発 ァームウェア開発 Copyright © Fixstars Group 11
ROS2の テストフレームワーク 徹底理解 Copyright © Fixstars Group
本セミナーのねらい ⚫ ソフトウェアの品質向上にはテストは欠かせないが、ROS2ではどういった テストが可能なのか、どのように実現されているか、どのように利用すれば 良いかの情報が少ない ⚫ そこで、本セミナーではサンプルを交えつつ、ROS2におけるテストについ て網羅的な解説を行う ⚫ サンプルは ROS2 Humble で動作確認済み Copyright © Fixstars Group 13
アジェンダ ⚫ テストとは ⚫ ROS2で可能なテスト/lint ⚫ サンプルアプリでのテスト実装 ⚫ その他TIPS Copyright © Fixstars Group 14
テストとは Copyright © Fixstars Group
テストとは ⚫ ソフトウェアが正しく作られているか確認する作業 ⚫ テストの分類 ○ 機能テスト ■ ○ 単体テスト、結合テスト、システムテスト、etc. 非機能テスト ■ パフォーマンステスト、ストレステスト、保守性テスト、etc. ⚫ テストがないと何が困る? ○ 関数やシステムが正しく動作しているか確認できない ⚫ とはいえ、手作業でテストを行うのは大変 ○ → テストフレームワークを使って自動化したい Copyright © Fixstars Group 16
テストとは ⚫ ソフトウェアが正しく作られているか確認する作業 ⚫ テストの分類 ○ 機能テスト ■ ○ 単体テスト、結合テスト、システムテスト、etc. 非機能テスト ■ パフォーマンステスト、ストレステスト、保守性テスト、etc. ⚫ テストがないと何が困る? ○ 関数やシステムが正しく動作しているか確認できない ⚫ とはいえ、手作業でテストを行うのは大変 ○ → テストフレームワークを使って自動化したい ROS2におけるテスト/テストフレームワークの使い方を解説する Copyright © Fixstars Group 17
ROS2でのテストの実行方法 ⚫ ros2 では colcon test でテストを実行する ○ テストに成功した場合 Copyright © Fixstars Group 18
ROS2でのテストの実行方法 ⚫ ros2 では colcon test でテストを実行する ○ テストに失敗した場合 Copyright © Fixstars Group 19
ROS2でのテストの実行方法 ⚫ colcon test-result で成否結果を得られる 終了ステータスが非ゼロであれば 失敗 Copyright © Fixstars Group 20
ROS2でのテストの実行方法 ⚫ colcon test-result で成否結果を得られる XML形式でレポートを得られる Copyright © Fixstars Group 21
ROS2でのテストの実行方法 ⚫ 詳細を見る時は colcon test-result --verbose … Copyright © Fixstars Group 22
… Copyright © Fixstars Group 23
ROS2で可能なテスト /lint Copyright © Fixstars Group
ROS2で可能なテスト/lint ⚫ 公式で提供されているもの ament_cmake ament_python ⚫ https://github.com/ament/ament_cmake ⚫ ament_cmakeの拡張としてテストルー ルが存在 ⚫ 基本的に python のテストの仕組みに則っ ている ⚫ pytest と unittest が使用可能 共通 ⚫ https://github.com/ros2/launch ⚫ launch システムを使用したテストフレームワークが存在 ⚫ https://github.com/ament/ament_lint ⚫ lint のための python ツールと ament_cmake 拡張が存在 Copyright © Fixstars Group 25
ROS2で可能なテスト/lint ⚫ 一覧(解説するもの) ament_cmake launch integration test lint (その2) add_test launch_testing ament_clang_tidy ament_cmake_test launch_pytest ament_cppcheck ament_cmake_gtest ament_cmake_gmock ament_cpplint lint (その1) ament_pclint ament_xmllint ament_flake8 ament_lint_cmake ament_mypy ament_copyright ament_pep257 pytest ament_clang_format ament_pycodestyle unittest ament_uncrustify ament_pyflakes ament_cmake_pytest ament_python Copyright © Fixstars Group 26
ROS2で可能なテスト/lint ⚫ 公式で提供されているもの ament_cmake ament_python ⚫ https://github.com/ament/ament_cmake ⚫ ament_cmakeの拡張としてテストルー ルが存在 ⚫ 基本的に python のテストの仕組みに則っ ている ⚫ pytest と unittest が使用可能 共通 ⚫ https://github.com/ros2/launch ⚫ launch システムを使用したテストフレームワークが存在 ⚫ https://github.com/ament/ament_lint ⚫ lint のための python ツールと ament_cmake 拡張が存在 Copyright © Fixstars Group 27
ament_cmake でのテスト 名前 ターゲット 概要 add_test any ctest (cmake のテストフレームワーク) の機能 ament_cmake でのテストは最終的に add_test の呼び出しとなる ament_cmake_test any ament_cmake が提供するテスト用のマクロ 他のテスト拡張から呼ぶことが想定されているように見える ament_cmake_gtest C/C++ gtest を使うための ament_cmake 拡張 ament_cmake_gmock C/C++ gmock を使うための ament_cmake 拡張 ament_cmake_pytest Python pytest を使うための ament_cmake 拡張 ament_cmake_nose Python テストフレームワークの nose 向けの拡張 nose自体2015年で更新が止まっているので解説を省略 Copyright © Fixstars Group 28
● add_test ● ament_cmake_test ament_cmakeでのテスト ● ament_cmake_gtest ● ament_cmake_gmock ● ament_cmake_pytest Copyright © Fixstars Group 29
概要 ⚫ CMakeに付属しているテストフレームワークである ctest にテストを登録 ○ ○ https://cmake.org/cmake/help/latest/manual/ctest.1.html https://cmake.org/cmake/help/latest/command/add_test.html ○ ○ 以降の全ての ament_cmake 向けのテストは最終的に add_test の呼び出しに繋がっている 任意のテストを作りたい場合も add_test を使えば実行されるようになる ■ とはいえ、あまり使う場面はなさそう ⚫ ament_cmake (純粋なCMakeも) において colcon test は ctest の実行となる ⚫ CMake記述例 # 成功 add_test( NAME test_success COMMAND bash -c "exit 0" ) # 失敗 add_test( NAME test_failure COMMAND bash -c "exit 1" ) 合否判定は単純で、プログラムの終了コードを見ている • 0 → 成功 • 0 以外 → 失敗 Copyright © Fixstars Group 30
実行例 $ colcon test –packages-select example_ctest –event-handlers console_direct+ … test 1 Start 1: test_success 1: Test command: /usr/bin/bash “-c” “exit 0” 1: Test timeout computed to be: 1500 1/2 Test #1: test_success ..................... Passed test 2 Start 2: test_failure 2: Test command: /usr/bin/bash "-c" "exit 1" 2: Test timeout computed to be: 1500 2/2 Test #2: test_failure .....................***Failed ←成功 0.00 sec ←失敗 0.00 sec 50% tests passed, 1 tests failed out of 2 Total Test time (real) = 0.00 sec The following tests FAILED: 2 - test_failure (Failed) Errors while running CTest … Copyright © Fixstars Group 31
● add_test ● ament_cmake_test ament_cmakeでのテスト ● ament_cmake_gtest ● ament_cmake_gmock ● ament_cmake_pytest Copyright © Fixstars Group 32
概要 ⚫ ament_cmake が提供するテスト用のマクロ ○ ○ https://github.com/ament/ament_cmake/blob/rolling/ament_cmake_test/cmake/ament_add_test.cmake 自前でテストを実装したい時以外は使う機会はなさそう ⚫ 最終的には add_test の呼び出しになるが、追加の設定やオプションがある ○ テスト実行を打ち切るまでのタイムアウト (デフォルト60秒) ○ テストをスキップするかどうかの選択 ○ etc. (詳しくは CMakeマクロのドキュメントコメントを参照) ← bash ベースのテストフレームワークの bats を使用 Copyright © Fixstars Group 33
CMake記述例
⚫ bash ベースのテストフレームワークである bats を使用
CMakeLists.txt
set(result_dir ${AMENT_TEST_RESULTS_DIR}/${PROJECT_NAME}/test_bats)
ament_add_test(test_bats
# 実行コマンド
COMMAND bats -F junit -o ${result_dir} test.bats
# 標準出力の出力先
OUTPUT_FILE ${CMAKE_BINARY_DIR}/ament_cmake_test/test_bats.txt
# 実行結果(テストレポート)の保存先
RESULT_FILE ${result_dir}/TestReport-test.bats.xml
# テスト実行のタイムアウト
TIMEOUT 10
# テスト実行ディレクトリ
WORKING_DIRECTORY $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/test>
)
Copyright © Fixstars Group
34
実行例
$ colcon test --packages-select example_ament_cmake_test
…
$ colcon test-result --verbose
build/example_ament_cmake_test/Testing/20221127-1617/Test.xml: 2 tests, 0 errors, 1 failure, 0 skipped
- test_bats
<<< failure message
-- run_test.py: invoking following command in '/workspaces/test-methodlogy/src/one-byone/03_example_ament_cmake_test/test':
- bats -F junit -o /workspaces/testmethodlogy/build/example_ament_cmake_test/test_results/example_ament_cmake_test/test_bats test.bats
1..2
ok 1 Test success in 0sec
not ok 2 Test failure in 0sec
-- run_test.py: return code 1
-- run_test.py: verify result file '/workspaces/testmethodlogy/build/example_ament_cmake_test/test_results/example_ament_cmake_test/test_bats/TestReport-test.bats.xml'
>>>
build/example_ament_cmake_test/test_results/example_ament_cmake_test/test_bats/TestReport-test.bats.xml: 2 tests, 0
errors, 1 failure, 0 skipped
- test.bats Test failure
<<< failure message
>>>
Summary: 5 tests, 0 errors, 2 failures, 0 skipped
Copyright © Fixstars Group
35
C++でテストを記述する場合 CMakeLists.txt add_executable(test_executable test/test.cpp ) CMakeの方法の則って実行ファイルを 作る ament_add_test(test_doctest COMMAND $<TARGET_FILE:test_executable> ) 実行ファイルを COMMAND として渡す。 $<TARGET_FILE:test_executable>は Generator Expressions で、 test_executable へのパスを得られる。 Copyright © Fixstars Group 36
● add_test ● ament_cmake_test ament_cmakeでのテスト ● ament_cmake_gtest ● ament_cmake_gmock ● ament_cmake_pytest Copyright © Fixstars Group 37
概要 ⚫ gtest (GoogleTest) を使うための ament_cmake 拡張 ○ https://github.com/ament/ament_cmake/blob/rolling/ament_cmake_gtest/cmake/ament_add_gtest.cmake ⚫ gtest は C/C++向けのテストフレームワーク ○ ○ https://github.com/google/googletest OpenCVにある入門ガイド : http://opencv.jp/googletestdocs/primer.html ⚫ ROS2でC++コードをテストする際はおおよそこれを使うことになる Copyright © Fixstars Group 38
CMake記述例 add_library(myadd SHARED src/add.cpp ) target_include_directories(myadd PUBLIC $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include> ) ライブラリ myadd を作成 if(BUILD_TESTING) find_package(ament_cmake_gtest REQUIRED) ament_add_gtest(myadd_gtest test/add_test.cpp) target_link_libraries(myadd_gtest myadd) endif() Copyright © Fixstars Group myadd をテストする myadd_gtest を作成 39
テストの記述例
example_ament_cmake_gtest/add.hpp
#pragma once
int add(int a, int b);
test/add_test.cpp
テストの書き方はgtestの作法に従う
#include <example_ament_cmake_gtest/add.hpp>
#include <gtest/gtest.h>
TEST(add, success) {
ASSERT_EQ(add(1, 2), 3);
}
成功するテスト
add(1, 2) を呼び出した時の結果は3になるべき
TEST(add, failure) {
ASSERT_EQ(add(1, 2), 4);
}
失敗するテスト
add(1, 2) を呼び出した時の結果は4になるべき
※テストに失敗した時の表示を見るためのもので実際はこのようなテストは書かない
Copyright © Fixstars Group
40
実行例(1/2) $ colcon test --packages-select example_ament_cmake_gtest … $ colcon test-result –verbose build/example_ament_cmake_gtest/Testing/20221113-0648/Test.xml: 1 test, 0 errors, 1 failure, 0 skipped - myadd_gtest <<< failure message -- run_test.py: invoking following command in '/workspaces/test-methodlogy/build/example_ament_cmake_gtest': - /workspaces/test-methodlogy/build/example_ament_cmake_gtest/myadd_gtest --gtest_output=xml:/workspaces/testmethodlogy/build/example_ament_cmake_gtest/test_results/example_ament_cmake_gtest/myadd_gtest.gtest.xml Running main() from /opt/ros/humble/src/gtest_vendor/src/gtest_main.cc [==========] Running 2 tests from 1 test suite. [----------] Global test environment set-up. [----------] 2 tests from add [ RUN ] add.success [ OK ] add.success (0 ms) [ RUN ] add.failure /workspaces/test-methodlogy/src/one-by-one/04_example_ament_cmake_gtest/test/add_test.cpp:9: Failure Expected equality of these values: add(1, 2) Which is: 3 4 [ FAILED ] add.failure (0 ms) [----------] 2 tests from add (0 ms total) Copyright © Fixstars Group 41
実行例(2/2)
[----------] Global test environment tear-down
[==========] 2 tests from 1 test suite ran. (0 ms total)
[ PASSED ] 1 test.
[ FAILED ] 1 test, listed below:
[ FAILED ] add.failure
1 FAILED TEST
-- run_test.py: return code 1
-- run_test.py: inject classname prefix into gtest result file '/workspaces/testmethodlogy/build/example_ament_cmake_gtest/test_results/example_ament_cmake_gtest/myadd_gtest.gtest.xml'
-- run_test.py: verify result file '/workspaces/testmethodlogy/build/example_ament_cmake_gtest/test_results/example_ament_cmake_gtest/myadd_gtest.gtest.xml'
>>>
build/example_ament_cmake_gtest/test_results/example_ament_cmake_gtest/myadd_gtest.gtest.xml: 2 tests, 0 errors, 1 failure, 0 skipped
- example_ament_cmake_gtest.add failure
<<< failure message
/workspaces/test-methodlogy/src/one-by-one/04_example_ament_cmake_gtest/test/add_test.cpp:9
Expected equality of these values:
add(1, 2)
Which is: 3
4
>>>
Summary: 3 tests, 0 errors, 2 failures, 0 skipped
Copyright © Fixstars Group
42
● add_test ● ament_cmake_test ament_cmakeでのテスト ● ament_cmake_gtest ● ament_cmake_gmock ● ament_cmake_pytest Copyright © Fixstars Group 43
概要 ⚫ gmock (GoogleMock) を使うための ament_cmake 拡張 ○ https://github.com/ament/ament_cmake/blob/rolling/ament_cmake_gmock/cmake/ament_add_gmock.cmake ⚫ gmock は C/C++向けのモックフレームワーク ○ ○ https://github.com/google/googletest (gtest に含まれる) OpenCVにある入門ガイド : http://opencv.jp/googlemockdocs/fordummies.html ⚫ ROS2でC++でモックを使ったテストをする際はだいたいこれを使うことに なる Copyright © Fixstars Group 44
CMake記述例 add_library(mylib SHARED src/foo.cpp ) target_include_directories(mylib PUBLIC $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include> ) if(BUILD_TESTING) find_package(ament_cmake_gmock REQUIRED) ament_add_gmock(my_ament_cmake_gmock test/foo_mock.cpp) target_link_libraries(my_ament_cmake_gmock mylib) endif() Copyright © Fixstars Group 45
テストの記述例
example_ament_cmake_gmock/foo.hpp
#pragma once
class Foo
{
public:
virtual bool func(int a) = 0;
};
テスト対象は 関数 bar
bar は、
1. クラス Foo のインスタンス fooを引数として取り
2. 0 を引数として foo->func を呼び出し
3. foo->func の返り値を bar の返り値として返す
bool bar(Foo * foo);
bar のテストで確認したいのは、
1. func が呼び出されていること
2. その引数が0であること
3. func が true を返した時、 bar も true を返すこと
src/foo.cpp
#include "example_ament_cmake_gmock/foo.hpp"
bool bar(Foo *foo) { return foo->func(0); }
Copyright © Fixstars Group
46
テストの記述例
test/foo_mock.cpp
#include <example_ament_cmake_gmock/foo.hpp>
#include <gmock/gmock.h>
class MockFoo : public Foo
{
public:
MOCK_METHOD1(func, bool(int));
};
TEST(bar, success) {
using namespace testing;
MockFoo mock_foo;
EXPECT_CALL(mock_foo, func(0))
.Times(1)
.WillOnce(Return(true));
モッククラスの作成
//
//
//
//
EXPECT_EQ(bar(&mock_foo), true);
}
テストの書き方は
gmockの作法に従う
mock_fooの使われ方の想定は、
0を引数としてfuncが呼び出されること
1度だけ呼ばれること
funcはtrueを返す
モックオブジェクトを設定
テスト
Copyright © Fixstars Group
47
実行例(1/2)
$ colcon test --packages-select example_ament_cmake_gmock
…
$ colcon test-result --verbose
build/example_ament_cmake_gmock/Testing/20221113-1555/Test.xml: 1 test, 0 errors, 1 failure, 0 skipped
- my_ament_cmake_gmock
<<< failure message
-- run_test.py: invoking following command in '/workspaces/test-methodlogy/build/example_ament_cmake_gmock':
- /workspaces/test-methodlogy/build/example_ament_cmake_gmock/my_ament_cmake_gmock --gtest_output=xml:/workspaces/test失敗するケースも追加
methodlogy/build/example_ament_cmake_gmock/test_results/example_ament_cmake_gmock/my_ament_cmake_gmock.gtest.xml
Running main() from gmock_main.cc
EXPECT_CALL(mock_foo, func(0))
[==========] Running 2 tests from 1 test suite.
.Times(2) // 2回呼ばれること
[----------] Global test environment set-up.
[----------] 2 tests from bar
.WillRepeatedly(Return(true));
[ RUN
] bar.success
[
OK ] bar.success (0 ms)
[ RUN
] bar.failure
/workspaces/test-methodlogy/src/one-by-one/05_example_ament_cmake_gmock/test/foo_mock.cpp:23: Failure
Actual function call count doesn't match EXPECT_CALL(mock_foo, func(0))...
Expected: to be called twice
Actual: called once - unsatisfied and active
[ FAILED ] bar.failure (0 ms)
[----------] 2 tests from bar (0 ms total)
Copyright © Fixstars Group
48
実行例(2/2)
[----------] Global test environment tear-down
[==========] 2 tests from 1 test suite ran. (0 ms total)
[ PASSED ] 1 test.
[ FAILED ] 1 test, listed below:
[ FAILED ] bar.failure
1 FAILED TEST
-- run_test.py: return code 1
-- run_test.py: inject classname prefix into gtest result file '/workspaces/testmethodlogy/build/example_ament_cmake_gmock/test_results/example_ament_cmake_gmock/my_ament_cmake_gmock.gtest.xml'
-- run_test.py: verify result file '/workspaces/testmethodlogy/build/example_ament_cmake_gmock/test_results/example_ament_cmake_gmock/my_ament_cmake_gmock.gtest.xml'
>>>
build/example_ament_cmake_gmock/test_results/example_ament_cmake_gmock/my_ament_cmake_gmock.gtest.xml: 2 tests, 0 errors, 1 failure, 0
skipped
- example_ament_cmake_gmock.bar failure
<<< failure message
/workspaces/test-methodlogy/src/one-by-one/05_example_ament_cmake_gmock/test/foo_mock.cpp:23
Actual function call count doesn't match EXPECT_CALL(mock_foo, func(0))...
Expected: to be called twice
Actual: called once - unsatisfied and active
>>>
Summary: 3 tests, 0 errors, 2 failures, 0 skipped
Copyright © Fixstars Group
49
● add_test ● ament_cmake_test ament_cmakeでのテスト ● ament_cmake_gtest ● ament_cmake_gmock ● ament_cmake_pytest Copyright © Fixstars Group 50
概要 ⚫ pytest を使うための ament_cmake 拡張 ○ https://github.com/ament/ament_cmake/tree/rolling/ament_cmake_pytest ⚫ pytest は python のテストフレームワーク ○ https://docs.pytest.org/en/stable/ ⚫ ament_cmake は基本的に C/C++ を扱うが、そこに pytest によるテストを混 ぜたい時に使う Copyright © Fixstars Group 51