[ 
https://issues.apache.org/jira/browse/GROOVY-8159?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15970472#comment-15970472
 ] 

Jochen Theodorou commented on GROOVY-8159:
------------------------------------------

I think it cannot be done for Groovy´s assert in general, simply because of its 
nature. It is a whole class different than what junit does.

(1) numbers of operands is 1 to n. "assert foo" will try to convert foo to 
boolean using Groovy truth, the error message is printed if it evals to false. 
Since there is only one operand, there is nothing to compare. This can probably 
be compared best to assertTrue. What does idea do for this?
(2) "==" is not the only operation. Anything can evaluate to boolean in Groovy 
and so anything can be used for an assert. But the most obvious ones besides == 
are surely the other boolean operations like a&&b, a>b and so on. Again a 
"Click to see difference" would be misplaced. Accordingly this maps to a whole 
lot of junit methods and matchers (I hope matchers was not TestNG)
(3) evaluation result tracing. What assert actually does is to trace all the 
results of all the steps when evaluating the expression given to an assert. So 
for "assert foo" we trace the value of foo; for "assert a<b" we trace the value 
of a and b; for "assert a*x^2+b*x+c == y" we trace the values of a,x,b,c and y 
as well as for steps of the calculation in between.

Accordingly, right now assert does not know or care if something is ==, it just 
takes the final boolean of that and acts accordingly. The only way I see we 
could support a "Click to see difference" would be to recognize in the compiler 
we do an assert with == and then call an assert function, which would produce a 
slightly different exception, which prints the results in a more junit style, 
additionally to the normal assert message.

Which means... what would you need from our side to be available to be able to 
implement the requested feature on your side?

> Make assert output easy to parse
> --------------------------------
>
>                 Key: GROOVY-8159
>                 URL: https://issues.apache.org/jira/browse/GROOVY-8159
>             Project: Groovy
>          Issue Type: Improvement
>          Components: groovy-runtime
>    Affects Versions: 2.4.10
>            Reporter: Iurii
>
> Based on https://youtrack.jetbrains.com/issue/IDEA-171275
> IntelliJ IDEA provides great feature: "Click to see difference" in test 
> console.
> It's very useful because it opens comparison windows where differences are 
> highlighted.
> It's supported for JUnit assertXXX but not for Groovy assert because: 
> "JUnit's ComparisonFailure contains all necessary data which can be rendered 
> later while Groovy's PowerAssertionError contains already rendered message 
> which is hard to parse (if it's even possible)"
> Can assert output be improved so that IDE can parse it?



--
This message was sent by Atlassian JIRA
(v6.3.15#6346)

Reply via email to