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