Android Learning note-junit Unit test

Source: Internet
Author: User

We all know that testing is essential for programmers, so, to do the Android program, you have to learn to use JUnit, which is a bit more complicated than the JUnit test in Java, requires some configuration, and the next hungry, let's introduce how to use JUnit testing.

The first step:

1, new package: Package name is our "business method to test after registration plus +.test".

2, Build class: The class name is "test+ the class name to test."

3, Build Method: The method name is "test+ the method name to test."

Of course, this is not something that must be observed, and knowledge as an object-oriented development, we need such a specification.

Like what:

Step Two:

We need to configure the instrumentation instruction set with User-libray, where the content will not be written, and we can do so.

1, new Android test project.

  

After 2,next, we select the project to be tested in the list,

3, after determining, we in the generated test project in the Androidmanifest.xml file is not able to find we need two nodes of the writing, direct copy,

4, direct copy, instrumentation and User-libray node, to our test project, we need to note that the instrumentation to be under the Mainfest node, The User-libray is under the application node.

Then select the method you want to test, select Run as-->junit test, you can do the Android unit test.

Android Learning note-junit Unit test

Related Article

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.