Unit testing can be done in Android studio

Source: Internet
Author: User
Write Unit Test class

1. Create a Unit Test folder, which is a new package for unit tests that holds the class for unit tests.

2. Create a class such as exampletest, and note that you want to inherit from the Instrumentationtestcase class.

3. Create a method that starts with test, such as Testjson

To configure unit tests for a project

1. Click "run-> Edit Configurations", then click "+" from the left pop-up list, select Add an Android Tests, then rename it to the desired name in the upper right corner.

2. Select your current module, such as app, from the drop-down menu.

3. Select the "All on package" option, and then select the test folder you just created. You can also select the "All in Module" option so that Android Studio will automatically find all the test units in your entire module, and you can also specify a class or even a test method with another option.

When configured, it resembles the following.

    

4. You should now see that the test case has been configured as a running project on the toolbar above Android studio, as shown in:

    

Run unit Tests

1. Select the Unit test item and click Run ...

2. Right-click the method you want to run, click Run ...

Unit testing can be done in Android studio

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.