All Java code in the engine should now be able to be tested with Robolectric 3.8 and JUnit 4. The test suite has been added after the bulk of the Java code was first written, so most of these classes do not have existing tests. Ideally code after this point should be tested, either with unit tests here or with integration tests in other repos.
test/
matching the path and name of the class under test. For example, shell/platform/android/io/flutter/util/Preconditions.java
-> shell/platform/android/**test**/io/flutter/util/Preconditions**Test**.java
.sources
of the robolectric_tests
build target in /shell/platform/android/BUILD.gn
. This compiles the test class into the test jar.@SuiteClasses
annotation in FlutterTestSuite.java
. This makes sure the test is actually executed at run time.testing/run_tests.py [--type=java] [--java-filter=<test_class_name>]
.See Updating Embedding Dependencies.