You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@jmeter.apache.org by bu...@apache.org on 2017/09/18 19:40:37 UTC
[Bug 61534] New: Convert AssertionError to a failed assertion in the
JSR223Assertion
https://bz.apache.org/bugzilla/show_bug.cgi?id=61534
Bug ID: 61534
Summary: Convert AssertionError to a failed assertion in the
JSR223Assertion
Product: JMeter
Version: 3.2
Hardware: All
OS: All
Status: NEW
Severity: enhancement
Priority: P2
Component: Main
Assignee: issues@jmeter.apache.org
Reporter: felix.schumacher@internetallee.de
Target Milestone: ---
Created attachment 35333
--> https://bz.apache.org/bugzilla/attachment.cgi?id=35333&action=edit
Catch AssertionError on assertions and use them to fill in the failure message
After seeing Philippes commits for JDBC tests that used groovy for assertions.
I thought how much shorter those assertions could be, if he could have written:
def list = vars.getObject('result')
assert list.size() == 1
assert list[0]['AUTHOR'] == '...'
instead of the current version
def list = vars.getObject('result');
if (list.size()==1) {
def map = list.get(0);
if(map.get('AUTHOR').equals('Philip K. Dick')) {
AssertionResult.setFailure(false);
} else {
AssertionResult.setFailure(true);
AssertionResult.setFailureMessage("Expected first row AUTHOR to
be equal to 'Philip K. Dick'");
}
} else {
AssertionResult.setFailure(true);
AssertionResult.setFailureMessage('Expected 1 row in result,
got:'+list.size());
}
--
You are receiving this mail because:
You are the assignee for the bug.
[Bug 61534] Convert AssertionError to a failed assertion in the
JSR223Assertion allowing users to use assert in their code
Posted by bu...@apache.org.
https://bz.apache.org/bugzilla/show_bug.cgi?id=61534
--- Comment #5 from Philippe Mouawad <p....@ubik-ingenierie.com> ---
(In reply to Philippe Mouawad from comment #4)
> Hi Felix,
> I think we should restore the 3.1 behaviour
as you proposed.
I have seen on SO a person complaining about this.
> Regards
--
You are receiving this mail because:
You are the assignee for the bug.
[Bug 61534] Convert AssertionError to a failed assertion in the
JSR223Assertion allowing users to use assert in their code
Posted by bu...@apache.org.
https://bz.apache.org/bugzilla/show_bug.cgi?id=61534
--- Comment #8 from Felix Schumacher <fe...@internetallee.de> ---
Created attachment 35685
--> https://bz.apache.org/bugzilla/attachment.cgi?id=35685&action=edit
Catch AssertionError on assertions and use them to fill in the failure message
This patch reverts the previous one and places the logic to catch
AssertionErrors higher up in the stack.
This fixes an regression introduced by r1775911 and reduces the noise in
jmeter.log introduced by thoses AssertionErrors.
--
You are receiving this mail because:
You are the assignee for the bug.
[Bug 61534] Convert AssertionError to a failed assertion in the
JSR223Assertion
Posted by bu...@apache.org.
https://bz.apache.org/bugzilla/show_bug.cgi?id=61534
Philippe Mouawad <p....@ubik-ingenierie.com> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |p.mouawad@ubik-ingenierie.c
| |om
--- Comment #1 from Philippe Mouawad <p....@ubik-ingenierie.com> ---
Great idea !
--
You are receiving this mail because:
You are the assignee for the bug.
[Bug 61534] Convert AssertionError to a failed assertion in the
JSR223Assertion allowing users to use assert in their code
Posted by bu...@apache.org.
https://bz.apache.org/bugzilla/show_bug.cgi?id=61534
Felix Schumacher <fe...@internetallee.de> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|RESOLVED |REOPENED
Resolution|FIXED |---
--- Comment #3 from Felix Schumacher <fe...@internetallee.de> ---
This "fix" was needed, as a result of r1775911, which changed a catch clause in
JMeterThread#processAssertion from Error to JMeterError. Therefore this patch
brings back part of the behaviour from 3.1 back.
I wonder if we should revert or at least extend the catch clause in
JMeterThread#processAssertion instead of JSR223Assertion, only.
--
You are receiving this mail because:
You are the assignee for the bug.
[Bug 61534] Convert AssertionError to a failed assertion in the
JSR223Assertion allowing users to use assert in their code
Posted by bu...@apache.org.
https://bz.apache.org/bugzilla/show_bug.cgi?id=61534
--- Comment #4 from Philippe Mouawad <p....@ubik-ingenierie.com> ---
Hi Felix,
I think we should restore the 3.1 behaviour
Regards
--
You are receiving this mail because:
You are the assignee for the bug.
[Bug 61534] Convert AssertionError to a failed assertion in the
JSR223Assertion allowing users to use assert in their code
Posted by bu...@apache.org.
https://bz.apache.org/bugzilla/show_bug.cgi?id=61534
Philippe Mouawad <p....@ubik-ingenierie.com> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|NEW |RESOLVED
Resolution|--- |FIXED
--- Comment #2 from Philippe Mouawad <p....@ubik-ingenierie.com> ---
Author: pmouawad
Date: Mon Oct 23 12:08:24 2017
New Revision: 1813001
URL: http://svn.apache.org/viewvc?rev=1813001&view=rev
Log:
Bug 61534 - Convert AssertionError to a failed assertion in the JSR223Assertion
allowing users to use assert in their code
Patch by Felix Schumacher
Bugzilla Id: 61534
Modified:
jmeter/trunk/src/components/org/apache/jmeter/assertions/JSR223Assertion.java
jmeter/trunk/xdocs/changes.xml
--
You are receiving this mail because:
You are the assignee for the bug.
[Bug 61534] Convert AssertionError to a failed assertion in the
JSR223Assertion allowing users to use assert in their code
Posted by bu...@apache.org.
https://bz.apache.org/bugzilla/show_bug.cgi?id=61534
Felix Schumacher <fe...@internetallee.de> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|REOPENED |NEEDINFO
--- Comment #7 from Felix Schumacher <fe...@internetallee.de> ---
One other thing, or rather two.
If we add AssertionError to the JMeterError catch clause, the failed assertions
will be marked as error instead of failure and (more importantly) log
stacktraces to jmeter.log.
So my questions are:
Should we log those assertion failures at all, or at debug level, only?
Is an AssertionError an error or a failure in respect to Assertions?
--
You are receiving this mail because:
You are the assignee for the bug.
[Bug 61534] Convert AssertionError to a failed assertion in the
JSR223Assertion allowing users to use assert in their code
Posted by bu...@apache.org.
https://bz.apache.org/bugzilla/show_bug.cgi?id=61534
Felix Schumacher <fe...@internetallee.de> changed:
What |Removed |Added
----------------------------------------------------------------------------
Resolution|--- |FIXED
Status|NEEDINFO |RESOLVED
--- Comment #9 from Felix Schumacher <fe...@internetallee.de> ---
Will be included in 4.0.
Date: Thu Jan 25 21:22:58 2018
New Revision: 1822229
URL: http://svn.apache.org/viewvc?rev=1822229&view=rev
Log:
Convert AssertionError to a failed assertion for all kind of assertions.
Fixing a regression introduced in 3.2. ThreadDeath has not to be catched
anymore,
as we are not using Error in the catch clause (which was the case before
r1775911
that introduced this regression).
Bugzilla Id: 61534
Modified:
jmeter/trunk/src/components/org/apache/jmeter/assertions/JSR223Assertion.java
jmeter/trunk/src/core/org/apache/jmeter/threads/JMeterThread.java
jmeter/trunk/xdocs/changes.xml
--
You are receiving this mail because:
You are the assignee for the bug.
[Bug 61534] Convert AssertionError to a failed assertion in the
JSR223Assertion allowing users to use assert in their code
Posted by bu...@apache.org.
https://bz.apache.org/bugzilla/show_bug.cgi?id=61534
--- Comment #6 from Felix Schumacher <fe...@internetallee.de> ---
(In reply to Philippe Mouawad from comment #4)
> Hi Felix,
> I think we should restore the 3.1 behaviour
> Regards
I tend to add AssertionError to JMeterError, as normal programs should not
catch Error (most are low level errors we can't handle correctly). That way, we
could get rid of catching ThreadDeath, too.
--
You are receiving this mail because:
You are the assignee for the bug.
[Bug 61534] Convert AssertionError to a failed assertion in the
JSR223Assertion allowing users to use assert in their code
Posted by bu...@apache.org.
https://bz.apache.org/bugzilla/show_bug.cgi?id=61534
Philippe Mouawad <p....@ubik-ingenierie.com> changed:
What |Removed |Added
----------------------------------------------------------------------------
Summary|Convert AssertionError to a |Convert AssertionError to a
|failed assertion in the |failed assertion in the
|JSR223Assertion |JSR223Assertion allowing
| |users to use assert in
| |their code
--
You are receiving this mail because:
You are the assignee for the bug.
[Bug 61534] Convert AssertionError to a failed assertion in the
JSR223Assertion allowing users to use assert in their code
Posted by bu...@apache.org.
https://bz.apache.org/bugzilla/show_bug.cgi?id=61534
Philippe Mouawad <p....@ubik-ingenierie.com> changed:
What |Removed |Added
----------------------------------------------------------------------------
Keywords| |PatchAvailable
--
You are receiving this mail because:
You are the assignee for the bug.