同时进行单元测试会出错

An error occurs if unit testing is performed at the same time

每个单元测试都没有出错。但是,当多个同时进行时会发生这种情况。是否有 Google 测试功能可以在单元测试之间休眠 运行?

p.s我不能修改源,因为它不是我的源。

以下命令会导致错误。

./ext_libs_test --gtest_filter=NAV_NC_0002_RouteController_Test*:IF1_LastDestination_Test*:NAV_NC_0029_TrafficInformationController_Test*:NAV_NC_0051_RouteMonitorListController_Test*:NAV_NC_0068_LocationInformationProvider_Test*:NAV_NC_0067_LearningRecordingController_Test*

我想在这些文件之间休眠。 如果您以这种方式键入每一个,则不会出现错误。

./ext_libs_test --gtest_filter=NAV_NC_0002_RouteController_Test*
./ext_libs_test --gtest_filter=IF1_LastDestination_Test*
./ext_libs_test --gtest_filter=NAV_NC_0029_TrafficInformationController_Test*
./ext_libs_test --gtest_filter=NAV_NC_0051_RouteMonitorListController_Test*
./ext_libs_test --gtest_filter=NAV_NC_0068_LocationInformationProvider_Test*
./ext_libs_test --gtest_filter=NAV_NC_0067_LearningRecordingController_Test*

您似乎在测试用例之间存在某种依赖关系,并且很可能(但不保证)睡眠不会掩盖这一事实。似乎隐藏问题的是 运行 每个测试用例的应用程序一次,所以我猜测一些静态数据不是每个测试用例初始化的,而是每个应用程序实例化的。尝试找到这个问题并解决它。