JUnit Test under Android

Source: Internet
Author: User

Android SDK 1.5 has been included in JUnit, used once, last night re-use when there is a bit of a problem, or decided to write a more detailed article for everyone and their future use, writing is also very convenient, JUnit under Android is an extension to JUnit under Java, which is basically similar to

about JUnit

JUnit is an open-source Java Unit Testing framework. In 1997, the development was completed by Erich Gamma and Kent Beck. The two bulls, Erich Gamma, is one of GOF Gang of four; Kent Beck is the founder of XP (Extreme programming) Extreme Programming (not Window XP). As the saying goes, "perfectly formed." "JUnit is designed to be very small, but it is very powerful. JUnit is very common in TDD (test driven development) test-driven development, and JUnit is a well-designed test framework that has been extended by Android to make it easier to use.

Some features of JUnit:
1) provides an API that allows you to write a reusable unit test case with a clear test result
2) provides three ways to display your test results, and can also extend
3) provides functionality for unit test cases to run in batches
4) ultra-lightweight and easy to use, no commercial deception and useless wizards
5) The whole frame is well designed and easy to expand

Android Junit Demo

First googlejunit the project, and then create a new test case:

public class Bookcase extends Androidtestcase {public void  test () {LOG.I ("bookcase", "Test");}}

Androidtestcase in fact itself is inherited from the testcase, if this operation is not able to run, need to androidmanifest.xml configuration:

After configuring this, you also need to application configure Uses-library:

The final step is to test the right-click Method Run As=>android Junit test, the result is as follows:

Accidentally Monday, you yards farmers (including me) Monday and the keyboard life, refueling ~

JUnit Test under Android

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.