After fussing with the database logic, all to get rid of those peskery (is that a word) database not closed messages, I'm planning to go back and code them properly. But, I'll do it as I run across them, because it's working now and I'm keen to complete the validation part.
One great benefits of the validation routine is I can ensure I have the correct level before continuing. Also, the SQL database now means that I don't have to re-initialize on a change of level. Well, I guess I could've always loaded all the words into the hash, regardless of level and had the same effect.
We can easily add a check for quiz end number:
public void testEndQuizNumTooHigh() throws Exception {
solo.clickOnButton(0);
solo.clearEditText(0);
solo.enterText(0, "5");
solo.clearEditText(2);
solo.enterText(2, "1000");
solo.clickOnButton(0);
assertTrue(this.solo.waitForText("Quiz end number must be less than or equal to 669"));
assertTrue(this.solo.searchText("Quiz end number must be less than or equal to 669"));
}
For some reason, this doesn't pass. Ok, the problem was had munged the text in the code by doing the above method like this:
Quiz end number must be less than or equal to 669" + lastNum
Ok, all clear. Now, for the less than test.
if (quizEndNum < quizStartNum ){
valid = false;
Toast.makeText(getBaseContext(),
"Quiz start number must be less than Quiz end number",
Toast.LENGTH_LONG).show();
}
And the test:
public void testStartQuizNumGEEndQuizNum() throws Exception {
solo.clickOnButton(0);
solo.clearEditText(0);
solo.enterText(0, "5");
solo.clearEditText(1);
solo.enterText(1, "100");
solo.clearEditText(2);
solo.enterText(2, "50");
solo.clickOnButton(0);
assertTrue(this.solo.waitForText("Quiz start number must be less than Quiz end number"));
assertTrue(this.solo.searchText("Quiz start number must be less Quiz end number"));
}
Odd. It's failing for no apparent reason. When I try to log the validation logic, I don't get anything on logcat.
Let's sprinkle around a few debug statements. And comment out all the test except the problem one.
Ok, there's the problem. "Quiz start number must be less than Quiz end number" <> "Quiz start number must be less than Quiz end number"
There were a couple of issue that snuck into these tests. They all had to do with being careful in coding. In the last one, I had an extra clickOnButton where it shouldn't be. In the source, I had given the wrong parameter name (lastNum instead of end quiz num), and actually reversed the "<" sign. So, it found a couple of errors in source, but here was extra debugging in test as well.
Ok, that more or less wraps up the validation logic. Now, I'll clean up some leftover code that's not long required. First, I'll run the Android junit tests, and commit.
Ok, let's refactor a little bit. I got rid of no longer needed flag and cleaned up related logic.
I just realized I should add 1 to the display error number to account for questions starting at 1. And sure enough it's flunking the test again. Hmmph. More debugging pure test code. I can tell by the wait time that it's not seeing it.
Ok, the problem was that I had two tests to change, not just one.
Ok, let's commit this and tackle some other changes.
No comments:
Post a Comment