What Christophe suggested requires editing the production code and you might not be keen on making the compile of production code dependent on compiling SVUnit. It's possible to interrogate the counter of each assertion in the simulation and check that the the desired assertion is pass/fail. Unfortunately, this isn't possible in the language itself. You can gen to these counters via the VPI, provided your tool supports the required object model elements.
I have the code on a different network and can't copy it here, but here's some pseudo-code for the required C code:
// Handle to the assertion being monitored
vpiHandle assert_handle;
// Global counters of how many time the monitored assertion has passed/failed
static int num_success;
static int num_failure;
// register this as a system function that takes the assertion as an argument
void monitor_assert() {
// get handle to assertion from argument
num_success = vpi_get(vpiAssertSuccessCovered, assert_handle);
num_failure = vpi_get(vpiAssertFailureCovered, assert_handle);
}
// register as a system function that returns 'num_success'
void get_assert_pass {
vpiHandle systfref = vpi_handle(vpiSysTfCall, NULL);
s_vpi_value temp_val;
temp_val.format = vpiIntVal;
temp_val.value.integer = vpi_get(vpiAssertSuccessCovered, assert_handle) - num_success;
vpi_put_value(systfref, &temp_val, NULL, vpiNoDelay);
}
// same for get_assert_fail
// ...
In SV:
`SVTEST(...)
$monitor_assert(<path_to_assert>);
// do stuff that makes assertion fail
// give assert time to trigger, as they are triggered in the observed region
#1;
// Check that there was only one fail in between the time you started to monitor the assertion and now
`FAIL_UNLESS($get_assert_fail() == 1)