junit - How to unit test a method that runs into an infinite loop for some input? -
this question occurred mind , want ask here.
the case intentional, write loop runs infinitely. how go unit testing it?
i ask because, situation may occur anywhere in code. method delegates several other methods, , want know
- how ran infinite loop
- what set of input caused it
- call method (from method) has caused this
i have no code written this. question purely knowledge sake if situation arises in future. please respond.
how unit test method runs infinite loop input?
you can test opposite: "how unit test method method not run longer xxxx milliseconds input". if test fails may have found candidate infinite loop.
nunit 2.5 has timeoutattribute makes test fail if test takes longer given amount of milliseconds.
Comments
Post a Comment