Store the assert failure result in a variable

batman

I'm new to groovy and I have doubt. Lets say I have this statement:

assert "king" == "kin" 

which will give me the assert failure as

Assertion failed: 

assert "king" == "kin" 
              | 
              false 

and stops the program. But what I want is, store the result (the failure message, if any say in GString) and proceed with the program.

Is that possible to do so?

Ant's

You can catch the AssertionError exception. Something like this:

try {
  assert ["hello"] == ["A"]
}
catch(AssertionError e) {
  result = e.getMessage()
}
println  result

This should work. ​

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

Store column result in variable

From Dev

Store function result into variable

From Dev

Store the result of a command in a variable

From Dev

store into variable a sudo result

From Dev

Store function result into variable

From Dev

Code Analysis Failure: Dead store to local variable

From Dev

Cannot store result into variable SQL

From Dev

Store the result of a Dynamic Query in a variable

From Dev

Store into variable result of function VBA

From Dev

Store cmd Find result to a variable

From Dev

Sed Fails to store the result into a variable

From Dev

Store Result of SVN Command in Variable

From Dev

How to store a query result in a variable

From Dev

Grep a variable and store the result in a vector in R

From Dev

Is it okay to store the result of a JQuery selector in a variable?

From Dev

How to store query result (a single document) into a variable?

From Dev

store result of select query into array variable

From Dev

store the result of xpath into an variable to assist in future query

From Dev

Cut of word from a string and store result to variable

From Dev

How to store in a variable an echo | cut result?

From Dev

Store result of array.sort in another variable

From Dev

Store a sql query result in pentaho variable

From Dev

store a result of a command into a variable using csh

From Dev

Store result of a for loop in Perl as a single variable

From Dev

how to store result of tail command in variable?

From Dev

How to store sed result in variable in tcsh

From Dev

Store mysql result in a bash array variable

From Dev

Store function result to variable for later use in PHP?

From Dev

Get the result of a WMIC command and store it in a variable

Related Related

HotTag

Archive