mirror of
https://github.com/flutter/flutter.git
synced 2026-02-20 02:29:02 +08:00
* Add native stacktrace on iOS * Add native stacktrace on Android * format and changing naming to errorWithCode on iOS * reformat * Remove stacktrace from decodeEnvelope, not needed. * Separate encodeErrorEnvelopeWithStacktrace with original encode function * Add unit tests * re-format * change comments for stacktrace * Remove changes for iOS Co-authored-by: Ben Li <libe@google.com>
Unit testing Java code
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.
Adding a new test
- Create a file under
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. - Add your file to the
sourcesof therobolectric_testsbuild target in/shell/platform/android/BUILD.gn. This compiles the test class into the test jar. - Add your class to the
@SuiteClassesannotation inFlutterTestSuite.java. This makes sure the test is actually executed at run time. - Write your test.
- Build and run with
testing/run_tests.py [--type=java] [--java-filter=<test_class_name>].
Q&A
My new test won't run. There's a "ClassNotFoundException".
See Updating Embedding Dependencies.