java - How to write JUnit testcase for unknown output -
how write junit testcase contains database transaction , not sure output .. let getting count query or id after querying based on several conditions . valid comparison if checking count > 0 or id > 0 ?
the whole concept of testing relies on matching actual state against expectations. implies expectations defined , known in advance.
i guess you're trying check transaction, in case should simulate data.
you can start predefined mock data (always same data), code query existing data , you'll know expected returned.
alternatively can create random data in beginning of test , build test flow know result of query.
although these approaches same, second 1 comes handy when required run tests in parallel on same schema/database. on other hand, maybe coding of such test trickier.
hope helps
Comments
Post a Comment