无法使用Docker容器中的Bazel运行JUnit5测试
我与Bazel有一个Kotlin项目,其中包含一些我运行的JUnit5测试:无法使用Docker容器中的Bazel运行JUnit5测试,docker,kotlin,junit,bazel,Docker,Kotlin,Junit,Bazel,我与Bazel有一个Kotlin项目,其中包含一些我运行的JUnit5测试: bazel run //my_service:tests 这是输出: Test run finished after 1195 ms [ 3 containers found ] [ 0 containers skipped ] [ 3 containers started ] [ 0 containers aborted ]
bazel run //my_service:tests
这是输出:
Test run finished after 1195 ms
[ 3 containers found ]
[ 0 containers skipped ]
[ 3 containers started ]
[ 0 containers aborted ]
[ 3 containers successful ]
[ 0 containers failed ]
[ 5 tests found ]
[ 0 tests skipped ]
[ 5 tests started ]
[ 0 tests aborted ]
[ 5 tests successful ]
[ 0 tests failed ]
5次测试成功。到目前为止,一切顺利。但当测试在Bazel Docker容器内运行时,我得到以下输出:
Test run finished after 79 ms
[ 1 containers found ]
[ 0 containers skipped ]
[ 1 containers started ]
[ 0 containers aborted ]
[ 1 containers successful ]
[ 0 containers failed ]
[ 0 tests found ]
[ 0 tests skipped ]
[ 0 tests started ]
[ 0 tests aborted ]
[ 0 tests successful ]
[ 0 tests failed ]
如您所见,没有找到任何测试。为什么?
我使用以下命令在容器内运行测试:
$ docker run -it -v $(pwd):/my_service --entrypoint "" l.gcr.io/google/bazel:2.2.0 /bin/bash
$ cd my_service
$ bazel run //my_service:tests
我在本地和Docker映像中都使用了Bazel2.2.0。为什么我没有得到相同的输出?我找到了解决方案。那真的很奇怪。我使用的是
register\u工具链
规则,而不是kt\u register\u工具链
。我真傻。我一直在努力让bzael与java/junit5一起工作,但运气不好。