Hi all,

I have a quick question. Is this a proper way of using blackbox testing to test the stringTokenizer class? If not, would you provide a proper example that displays the pass or fail.

string = "cat, dog";
    StringTokenizer token = new StringTokenizer(string, ",");	     
         if (token.countTokens() == 2)
	System.out.println("Passed");
	     else {
	     System.out.println("Fail");	     
	     }

Thanks, KimJack

Black box testing would involve trying to break your code by giving it invalid inputs and making sure it handles them appropriately, as well as giving it valid inputs and making sure it comes up with the right result. So I do not think your code counts as black box testing. . however, that isn't to say your test is invalid, it just isn't black box IMO.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.