mardi 20 février 2018

How to get complete coverage in endless loop?

I have a program that looks like this:

def foo():
    while True
        doThings()
        if something:
            break
        doMoreThings()
        doStuff()
    doFoo()

I test foo and my tests pass, but when looking at the code coverage using coverage only the lines before the break are covered. I know that doMoreThings() and doStuff() have been correctly executed otherwise my tests wouldn't pass, but I would like my coverage to reflect that they have been called. The problem is that the program always ends with the break so in the last loop coverage doesn't detect that the later code has been executed, how can I deal with this?

Aucun commentaire:

Enregistrer un commentaire