Testability
Information about testability:
- All changes within Fuchsia need to adhere to the Testability rubric.
- See also: Test environments
Scenic test packages
You can specify packages in these ways:
Everything:
--with //bundles/testsIndividually, if you want to build less packages:
--with //src/ui:tests --with //src/ui/lib/escher:escher_tests
Scenic and CQ
Tests are automatically run before submission by trybots for every change in
Fuchsia. See the fuchsia-x64-release and fuchsia-x64-asan bots on
https://ci.chromium.org/p/fuchsia/builders.
Add a new test suite to existing CQ tests
Most of the Scenic and Escher tests are written in
Googletest.
If you need to add test suites or test cases, you need to create test source files and add
them as a source of the test executables in corresponding BUILD.gn files.
Adding a test package to CQ
To add a test package to CQ, you need to:
- Create test components;
- Reference the test package;
- Specify test environments.
Create test components
To add a new test package to CQ, you need to create a test component including source files,
metadata and BUILD.gn file. See
Test component.
You can include multiple test executables in one single test package, and all of them will be
executed if you run fx test <test_package> on host.
Examples of test packages:
- allocation_unittests: //src/ui/scenic:allocation_unittests
- escher_tests: //src/ui/lib/escher:escher_tests
Reference the test package
To ensure the test is run on CQ, it requires an unbroken chain of dependencies that roll up to your
fx set command's available packages (expandable using the --with flag), typically
going through the all target of //bundles/packages/tests:all.
You need to make sure that there is a dependency chain from //bundles/packages/tests:all to
your test package. For more information, see
Testing FAQ documentation.
Specify test environments
To ensure that the test is run on CQ, you also need to specify a
test environment
for each test executable in the package inside the test's BUILD.gn file.
Generally the environment is set to environments = basic_envs.
This specifies the test should be run on both QEMU (for arm64), FEMU and NUC (for x64), and using
both debug and release builds. For running on other environments, refer to
Test environments.
Reference the test package transitively. For example, the packages above are
referenced by //bundles/packages/tests:all through //bundles/packages/tests:scenic.
Unit tests and integration tests
To run tests locally during development:
Running on device/emulator
Some of these tests require the test Scenic to connect to the real display controller.
Run fx shell killall scenic.cm to kill an active instance of Scenic.
Run all Scenic tests:
From host workstation, ensure
fx serveis running, then:fx test \ escher_tests \ allocation_unittests \ display_unittests \ flatland_unittests \ flatland_buffers_unittests \ flatland_display_compositor_pixeltests \ flatland_display_compositor_pixeltests_with_fake_display \ flatland_engine_unittests \ flatland_renderer_unittests \ input_unittests \ scenic_unittests \ scheduling_unittestsOr from Fuchsia target device:
runtests --names escher_unittests,input_unittests,a11y_manager_apptestsRun a specific test binary:
From host workstation, ensure
fx serveis running, then use the following command to run theescher_unitteststest component:fx test escher_unittestsRun a single test within a component:
From host workstation, ensure
fx serveis running, then:fx test escher_unittests -- --gtest_filter=NoOpMacTest.DummyTestCaseSee more documentation about the glob pattern for the filter arg.
Run a specific component
From your host workstation:
fx test fuchsia-pkg://fuchsia.com/escher_unittests#meta/escher_unittests.cm
Host tests
fx test --hostruns all host tests, but you probably only want to run Escher tests.- Escher: To run
escher_unittestslocally on Linux: follow instructions in Escher documentation.
Manual UI tests
After making big Scenic changes, you may want to do manual UI testing by running some example applications to see if there is any regression.
UI Examples
There are some examples available:
- flatland-rainbow
- Basic example of creating a UI using Flatland commands, and connecting it to the scene graph using one of two approaches:
- connecting to
fuchsia.element.GraphicalPresenter - (legacy) serving
fuchsia.ui.app.ViewProvider - Source:
//src/ui/examples/flatland-rainbow - Build dependency:
//src/ui/examples/flatland-rainbow - Package URIs:
fuchsia-pkg://fuchsia.com/flatland-examples#meta/flatland-rainbow.cmfuchsia-pkg://fuchsia.com/flatland-examples#meta/flatland-rainbow-vulkan.cm
To run these applications, you need to include the following dependency in your fx set
configuration:
fx set workbench_eng.x64 --with "//src/ui/examples"
Running UI examples
Running in session
You can launch the stories (modules) in any session you are in, via
ffx session add <component_name>. From your host workstation, run:
fx session add "fuchsia-pkg://fuchsia.com/flatland_examples#meta/flatland-rainbow.cm"
to present the View created in the flatland-rainbow component.