Android Write Test class

Source: Internet
Author: User

Because of many tutorials on the web, I don't say much. Here I will talk about the problems I have encountered.

In the Android Studio Authoring unit test class, two classes were written under the Androidtest package, as follows

   ImportJunit.framework.TestCase;

public class TestExtendsTestCase {
     Test1 MC =NewTest1();
public voidTest () {
       int num =Mc.< Span style= "COLOR: #cc7832" > < Span style= "COLOR: #cc7832" > < Span style= "COLOR: #808080" > < Span style= "COLOR: #cc7832" >testmethod (1, 2);
System.out.println ("This is test class =" + num);
      Assertequals (3, num);
}
}

< Span style= "COLOR: #9876aa" > < Span style= "Font-style:italic" > public class Test1 {
Span style= "COLOR: #cc7832" >public int testmethod (int x< Span style= "COLOR: #cc7832", int y) {
return x * y;
}
} /span>

 

< Span style= "COLOR: #cc7832" > < Span style= "COLOR: #808080" > < Span style= "COLOR: #cc7832" > but when I run the test class on the real machine is always in the load, not run past, helpless toss a while, on the virtual you on the run, this time it is possible, but reported a   

< Span style= "COLOR: #9876aa" > < Span style= "Font-style:italic" > < Span style= "COLOR: #ffc66d" > junit.framework.assertionfailederr Or:test method isn ' t public exception, check the next, try to change the Add method in the Test1 class to public (originally private), and then run on it can be

 

< Span style= "COLOR: #cc7832" > < Span style= "COLOR: #cc7832" > I am a novice, looking for more advice. This is the first time I have tried to write a blog, hoping to help the novice.

  

Android Write Test class

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.