Skip to content

Instantly share code, notes, and snippets.

@parisyup
Created June 3, 2024 08:32
Show Gist options
  • Save parisyup/dfe1b2a108fa9d860760d2262bf665a1 to your computer and use it in GitHub Desktop.
Save parisyup/dfe1b2a108fa9d860760d2262bf665a1 to your computer and use it in GitHub Desktop.
return "Fail";//no error found. Contract failed.
} catch (Exception e) {//catching the error to see if the contract passed
//check if gotten the expected error
String exceptionMessage = e.getMessage() != null ? e.getMessage() : "No exception message";
if (exceptionMessage.contains("Require a single command")) {
return "Pass"; //expected error found so the contract passes the test
} else {
return "Contract failed but with a different Exception: " + e.getMessage();//different error thrown. Contract failed
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment