H
Hoss Spence
In this scenario I am getting the next valid event in an infinite
while loop which sleeps a certain period of time looking for a change
in state e.g. expected file(s) in the file system that will appear at
some point and will continuously appear. Question is how would you
test this? Since you are in an infinite loop, the code once invoked,
never returns to the junit test. What I landed up doing was stubbing
the code and putting an iterator in. I have a setter that passes in a
max so it iterates to the number I want before exiting. Is this the
best way it can be done? I'm concerned that my actual code isn't
tested... just the stub but I don't see another way to test this. Note
I am looking for "state" changes based on different files it finds so
just invoking the classes beneath don't do the trick.
while loop which sleeps a certain period of time looking for a change
in state e.g. expected file(s) in the file system that will appear at
some point and will continuously appear. Question is how would you
test this? Since you are in an infinite loop, the code once invoked,
never returns to the junit test. What I landed up doing was stubbing
the code and putting an iterator in. I have a setter that passes in a
max so it iterates to the number I want before exiting. Is this the
best way it can be done? I'm concerned that my actual code isn't
tested... just the stub but I don't see another way to test this. Note
I am looking for "state" changes based on different files it finds so
just invoking the classes beneath don't do the trick.