Created
June 3, 2024 08:32
-
-
Save parisyup/dfe1b2a108fa9d860760d2262bf665a1 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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