Pega UnitTest, how to deal with Fault scenario when data entry allready in database
I am having some trouble in automating a Pega unit test with the following scenario. From a pega casetype/flow we are writing a (Person) entitity to the database. The happy flow scenario is no problem to test but where I am having some trouble in finding the correct way is to test the Fault scenario ie the Person record allready exists so the outcome of the flow is a fault. The test should still be green since the fault is expected but after having tried al sorts of properties and pages it seems the Pega Unit test allways fails.
So here is what we did, just for testing purposes. We build a test application on top of Pega PegaGP(7.40) called GPTestToo. in the casetype Add Vehicle we have added two test cases, one called AddVehicleHappy and one called AddVehicleDuplicateVIN. Both are adding a vehicle with the same VIN so we except the seceond testcase to fail. The message you get on failure of the second testcase is:
Flow processing failed as following errors were detected on pyWorkPage. Refer logs for more details. A vehicle already exists with the same Vehicle identification number. Please enter valid Vehicle identification number.
Which we are fully expecting but would like to catch this error in an assertion somehow and make it pass. The first warning we see in the tracer is indeed the duplicate vehicle warning message on pyWorkPage. So our first approach was to have an assertion on pyWorkPage for 'has errors'.
We tried a bunch of other assertions on other pages as well but cannot get this failure testcase to pas, maybe we are overlooking something here?