mardi 22 septembre 2015

JUNIT to skip IO handling and verify only the logic

I was asked some question like this in an interview.

So basically, the question is like this:

You have a method like below:

public void methodToBeTested() {
    //step 1 open file, if not exist create new one
    //step 2 String rst = reverseStr();
    //step 3 write rst to file in step 1
}

So the question is how to write a unit test to test only the reverseStr logic without doing the IO handling of step1 and step3 each time?

Aucun commentaire:

Enregistrer un commentaire