java - Testing Color class in android not working as expected -
i trying write test cases java class in android application, , doesn't seem work expected.
this test case:
public void testgetcolor() throws exception { shadescolor color = new shadescolor(100, 200, 250); assert.assertequals(color.rgb(100, 200, 250), color.getcolor()); assert.assertequals(100, color.getred()); assert.assertequals(200, color.getgreen()); assert.assertequals(250, color.getblue()); }
following shadescolor class.
public class shadescolor { int color; public shadescolor(int red, int green, int blue) { color = color.rgb(red, green, blue); } public int getcolor(){ return color; } public shadescolor interpolate(shadescolor endcolor, double percentage){ int red = (int)(this.getred() + (endcolor.getred() - this.getred()) * percentage); int green = (int)(this.getgreen() + (endcolor.getgreen() - this.getgreen()) * percentage); int blue = (int)(this.getblue() + (endcolor.getblue() - this.getblue()) * percentage); return new shadescolor(red, green, blue); } public int getred(){ return color.red(color); } public int getgreen(){ return color.green(color); } public int getblue(){ return color.blue(color); } }
when shadescolor constructor gets called, color integer value 0. since android.color isn't mocked default, added following line in build.gradle file
testoptions { unittests.returndefaultvalues = true }
am missing something?
Comments
Post a Comment