tree: fe0805b75131f8ef056362e62f579cd097ab7e5e [path history] [tgz]
  1. BUILD.gn
  2. README.md
  3. agent_services_tests/
  4. benchmarks/
  5. clipboard/
  6. common/
  7. component_context/
  8. embed_shell/
  9. intents/
  10. maxwell_integration/
  11. modular_config/
  12. modular_login_tests/
  13. modular_tests.json
  14. module_context/
  15. parent_child/
  16. queue_persistence/
  17. run_modular_tests.sh
  18. session_shell/
  19. sessionctl/
  20. story_shell/
  21. story_shell_factory/
  22. suggestion/
  23. trigger/
peridot/tests/README.md

Testing

Modular has two types of tests, unit tests and integration tests.

Unit tests

Unit tests are low-level tests written against the smallest testable parts of the code. Tests for some_class.{h,cc} are placed side-by-side the code being tested, in a some_class_unittest.cc file.

Unit tests are regular Google Test tests, although most of them use our own TestLoopFixture base class to conveniently run delayed tasks with a timeout, ensuring that a failing test does not hang forever.

All Modular unit tests in the peridot tree are built into a single modular_unittests binary, which can be executed on fuchsia by running /system/test/modular_unittests.

Integration tests

Integration tests are written against client-facing FIDL services exposed by Modular and run through the Test Runner framework in a fuchsia instance running on either the build host using QEMU or on a target device.

There are two ways to invoke the test suite, remotely from the build host or directly on the fuchsia instance.

Starting tests remotely from the build host

The test runner discovers the running fuchsia instance automatically, but will stop with an error if there is more than one. To fix the problem, specify the device name with the --server parameter.

In order to run tests from your workstation, a test_runner must be running under fuchsia. In order to start test_runner, you can either:

  • Use a gn module to automatically start test_runner at fuchsia boot time using boot_test.config. At build time on your workstation, do:
fx set x64 --monolith peridot/packages/products/test_modular
  • Alternatively, invoke test_runner manually after starting fuchsia. In a shell on your fuchsia device, do:
run test_runner

Each subdirectory of peridot/tests contains one integration test. They are all run together by the test runner as specified by the modular_tests.json configuration file:

fx exec garnet/bin/test_runner/run_test \
  --test_file=peridot/tests/modular_tests.json

Starting the test suite directly under fuchsia

run_modular_tests.sh is a command that runs all of the Modular tests. It is based on the Test Runner framework, but runs the tests without requiring test_runner to be running under fuchsia.

Run it from the fuchsia shell:

$ /pkgfs/packages/modular_tests/0/test/run_modular_tests.sh

You can also run specific tests by using their name. For example this will run only the link_update test (as described in modular_tests.json).

$ /pkgfs/packages/modular_tests/0/test/run_modular_tests.sh link_update