我正在bazel为我的项目构建和运行测试。
我想更深入地了解我的测试是如何运行的。我希望能够在我的 java 应用程序中看到记录器捕获的输出。
我尝试添加-s参数来开始我的测试,如下所示:bazel test -s //myproject:integration-test
它为我提供了有关如何调用测试的更多信息:
remote: Resolving deltas: 100% (101/101), completed with 18 local objects.
To github.com:Canva/canva.git
$ bazel test -s //myproject:integration-tests
WARNING: The following rc files are no longer being read, please transfer their contents or import their path into one of the standard rc files:
/nix/store/qsmyc0p2z1z3m06ch37hz49m0hz2c270-bazel-rc
INFO: Invocation ID: 2d17fb35-c72b-4152-bf14-2805027c6c01
INFO: Analyzed target //myproject:integration-tests (0 packages loaded, 0 targets configured).
INFO: Found 1 test target...
SUBCOMMAND: # //myproject:integration-tests [action 'Testing //myproject:integration-tests', configuration: cd8c76baa0169ef7c8b826ed0feb93200dd87a70639fd99286b8801aa9226239]
(cd /private/var/tmp/_bazel_antkong/cf188c7bd288685357ff03fcbb494066/execroot/com_canva_canva && \
exec env - \
CI='' \
DISPLAY=:1 \
EXPERIMENTAL_SPLIT_XML_GENERATION=1 \
FLAVOR=local \
JAVA_RUNFILES=bazel-out/darwin-fastbuild/bin/myproject/integration-tests.runfiles \
PATH=/nix/store/6ajpp69s5lf5krrdzy3mw1fs22vg1fqq-user-environment/bin \
PYTHON_RUNFILES=bazel-out/darwin-fastbuild/bin/myproject/integration-tests.runfiles \
RUNFILES_DIR=bazel-out/darwin-fastbuild/bin/myproject/integration-tests.runfiles \
RUN_UNDER_RUNFILES=1 \
TEST_BINARY=myproject/integration-tests \
TEST_INFRASTRUCTURE_FAILURE_FILE=bazel-out/darwin-fastbuild/testlogs/myproject/integration-tests/test.infrastructure_failure \
TEST_LOGSPLITTER_OUTPUT_FILE=bazel-out/darwin-fastbuild/testlogs/myproject/integration-tests/test.raw_splitlogs/test.splitlogs \
TEST_PREMATURE_EXIT_FILE=bazel-out/darwin-fastbuild/testlogs/myproject/integration-tests/test.exited_prematurely \
TEST_SIZE=large \
TEST_SRCDIR=bazel-out/darwin-fastbuild/bin/myproject/integration-tests.runfiles \
TEST_TARGET=//myproject:integration-tests \
TEST_TIMEOUT=900 \
TEST_TMPDIR=_tmp/73bce5ef685ff9d5d824b9a0b736db87 \
TEST_UNDECLARED_OUTPUTS_ANNOTATIONS=bazel-out/darwin-fastbuild/testlogs/myproject/integration-tests/test.outputs_manifest/ANNOTATIONS \
TEST_UNDECLARED_OUTPUTS_ANNOTATIONS_DIR=bazel-out/darwin-fastbuild/testlogs/myproject/integration-tests/test.outputs_manifest \
TEST_UNDECLARED_OUTPUTS_DIR=bazel-out/darwin-fastbuild/testlogs/myproject/integration-tests/test.outputs \
TEST_UNDECLARED_OUTPUTS_MANIFEST=bazel-out/darwin-fastbuild/testlogs/myproject/integration-tests/test.outputs_manifest/MANIFEST \
TEST_UNDECLARED_OUTPUTS_ZIP=bazel-out/darwin-fastbuild/testlogs/myproject/integration-tests/test.outputs/outputs.zip \
TEST_UNUSED_RUNFILES_LOG_FILE=bazel-out/darwin-fastbuild/testlogs/myproject/integration-tests/test.unused_runfiles_log \
TEST_WARNINGS_OUTPUT_FILE=bazel-out/darwin-fastbuild/testlogs/myproject/integration-tests/test.warnings \
TEST_WORKSPACE=com_canva_canva \
TZ=UTC \
XAUTHORITY=/dev/null \
XML_OUTPUT_FILE=bazel-out/darwin-fastbuild/testlogs/myproject/integration-tests/test.xml \
external/bazel_tools/tools/test/test-setup.sh myproject/integration-tests)
Aspect @mypy_integration//:mypy.bzl%mypy_aspect of //myproject:integration-tests up-to-date (nothing to build)
INFO: Elapsed time: 6.692s, Critical Path: 5.34s
INFO: 1 process: 1 processwrapper-sandbox.
INFO: Build completed successfully, 2 total actions
//myproject:integration-tests PASSED in 5.1s
Executed 1 out of 1 test: 1 test passes.
INFO: Build completed successfully, 2 total actions
Run Code Online (Sandbox Code Playgroud)
然而,这实际上不是我所追求的。我希望能够看到通过调用 java 代码中的记录器记录的输出:
private static final Logger logger = LoggerFactory.getLogger(
MyProject.class);
...
logger.info('It is executed')
Run Code Online (Sandbox Code Playgroud)
有没有我可以使用的开关,以便 bazel 可以打开日志记录?
use*_*975 14
运行 bazel test 时,请使用 --test_output 标志。请参阅文档。
bazel test --test_output=errors //...
Run Code Online (Sandbox Code Playgroud)
上面将在出现错误时显示测试输出,但您也可以请求它显示输出而不管成功失败:
bazel test --test_output=all //...
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
7351 次 |
| 最近记录: |