Android-specific test suites 编辑

There are several Android-specific test suites that run on the Firefox for Android codebase:

All of these suites require a functioning build of Firefox for Android — either a full build or an artifact build. All of the suites are configured by and invoked using Gradle.

Android-test

Runs Android-specific local unit tests.

These tests are local — they run on your development machine and do not require an Android device or Android emulator. Local unit tests are the fastest to develop and execute, but they can only test Java code; there's no connection to the Gecko rendering engine. Use these to test Java data structures and logic, and to ensure that basic Android integration works. They should always be preferred to on-device Robocop tests.

See https://developer.android.com/training/testing/unit-testing/local-unit-tests.html for more details.

Running android-test

To run android-test, first build Firefox for Android with your changes; then run

./mach android test

This will run the tests and report the results to stdout, as well as produce an HTML report. While developing, you can launch these tests from within Android Studio, which is the fastest way to iterate on code and tests.

Disabling one failing test

There is no manifest listing the Android local unit tests. To disable a single test, edit the source code and insert JUnit's @Ignore annotation before the existing @Test annotation. For example, to disable org.mozilla.gecko.permissions.testSuccessRunnableIsExecutedIfPermissionsAreGranted, add @Ignore as follows:

...

@RunWith(TestRunner.class)
public class TestPermissions {
    @Ignore
    @Test
    public void testSuccessRunnableIsExecutedIfPermissionsAreGranted() {
...

Contact information

android-test is currently owned by :sebastian and :nalexander. File tickets in the Firefox for Android product in Bugzilla.

Android-checkstyle

Verifies that the Java coding style is consistent throughout.

See http://checkstyle.sourceforge.net/index.html and https://docs.gradle.org/2.14/userguide/checkstyle_plugin.html for more details.

Running android-checkstyle

To run android-checkstyle, first build Firefox for Android with your changes; then run

./mach android checkstyle

This will run the tests and report the results to stdout, as well as produce an HTML report.

Disabling one failing test

In general, it's not sensible to allow Java code that doesn't observe the existing coding style; in this respect, this job is equivalent to the ESLint jobs that check the JavaScript coding style throughout the tree. However, the existing configuration can be tweaked and the set of files checked can be modified.

Contact information

android-checkstyle is currently owned by :mcomella and :nalexander. File tickets in the Firefox for Android product in Bugzilla.

android-findbugs

Ensures that the code avoids common Java coding errors.

Using this suite will allow the code to be analyzed to spot any design flaws or potential bugs. If an issue is found within the code, a warning will be identified and put into the correct category that the suite controls — this could be malicious, correctness, or just bad practice.

See http://findbugs.sourceforge.net/index.html and https://docs.gradle.org/2.14/userguide/findbugs_plugin.html for more details.

Running android-findbugs

To run android-findbugs, first build Firefox for Android with your changes; then run

./mach android findbugs

This will run the tests and report the results to stdout, as well as produce an HTML report.

Disabling one failing test

In general, it's not sensible to allow new Java code to land that findbugs detects issues with. However, the existing configuration can be tweaked and the set of files checked can be modified.

Contact information

android-checkstyle is currently owned by :mcomella and :nalexander. File tickets in the Firefox for Android product in Bugzilla.

android-lint

Ensure that the code avoids common Android coding errors.

Lint is a code scanning tool that identifies problems in the code regarding quality. It is a fast process that can be run on unexecuted code, and test cases are not needed for the process to be completed. Lint is a simple test that can assure you have a quality code.

See https://developer.android.com/studio/write/lint.html and http://tools.android.com/tips/lint for more details.

Running android-lint

To run android-lint, first build Firefox for Android with your changes; then run

./mach android lint

This will lint the code and report the results to stdout, as well as produce an HTML report. While developing, lint warnings should appear within Android Studio, although this is not infallible.

Disabling one failing test

In general, it's not sensible to allow new Java code to land that lint detects issues with. However, the existing configuration can be tweaked and some options can be modified.

Contact information

android-lint is currently owned by :sebastian and :nalexander. File tickets in the Firefox for Android product in Bugzilla.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据

词条统计

浏览:78 次

字数:9393

最后编辑:8年前

编辑次数:0 次

    我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
    原文