currently in production code, I have a function as such
public void doWork() {
... call functionA
... call functionB
... do other work
}
I have to test a case where I need to pause after functionA is called in doWork(). And there is no way for me to pause through testing framework
so I've changed the production to be
public void doWork() {
doWork(new CountdownLatch(0))
}
public void doWork(CountdownLatch latch) {
... call functionA with a latch and it calls latch.await()
}
Now, i can create a test case and test with doWork(new CountdownLatch(1))
But in production it will always be calling doWork() which in turn calls doWork(new CountdownLatch(0))
Is this unnecessary overhead just to be able to make the code test-able? or is this acceptable?
Aucun commentaire:
Enregistrer un commentaire