mardi 5 mai 2015

Java: How to test method behaviour of a class?

How can I test method behaviour of my class?

public class InfiniteWhileLoop {
    public void fun() {
        while (true) {
            // some code to test
        }
    }
}

I need to test method fun and make sure that it set the field to "xyz". The problem is I get an infinite loop. So I need to run while loop and let it to set the field and after that stop the loop.

Is it possible?

Aucun commentaire:

Enregistrer un commentaire