Skip to content

Commit

Permalink
v1.4.4 show dynamic information in custom verifynegative message
Browse files Browse the repository at this point in the history
  • Loading branch information
tim-buckland committed Feb 3, 2021
1 parent 9c425f4 commit 48185ab
Show file tree
Hide file tree
Showing 7 changed files with 36 additions and 20 deletions.
3 changes: 3 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ Version 1.42 onwards - https://github.com/Qarj/WebImblaze
---------------------------------
## WebImblaze Release History:

### Version 1.4.4 - Feb 3, 2021
* now possible to show dynamic details in custom verifynegative assertion message

### Version 1.4.3 - Jan 5, 2021
* fix for Linux file path handling when writing grabbed assets

Expand Down
19 changes: 15 additions & 4 deletions MANUAL.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Manual for WebImblaze version 1.4.3
# Manual for WebImblaze version 1.4.4

## Overview

Expand Down Expand Up @@ -606,6 +606,7 @@ not be found in the response. After the three bars, i.e. `|||`, the optional err
on failure is specified.

<br />

```xml
<autoassertions>
<autoassertion1>^((?!Copyright Example Company 2016).)*$</autoassertion1>
Expand All @@ -615,6 +616,7 @@ on failure is specified.
This second example automatically asserts that this copyright message appears in every response.

<br />

```xml
<autoassertions>
<autoassertion1>Error reference ([\w]+)|||Found error reference $capture1</autoassertion1>
Expand Down Expand Up @@ -1324,21 +1326,30 @@ verifynegative1: OutOfMemoryException
And also as per verifypositive, you can specify a custom message if that verification fails.

```
verifynegative: additional-search-results-btn|||Additional Search Results button should not be shown
verifynegative: additional-search-results-btn|||Additional Search Results button should not be shown
```

You can capture details, say an error reference, and put this in the error message.
In this example, assume the following was returned `Error reference #2349829.`.

```
verifynegative: Error reference ([^\.]*)|||Found error reference: $capture1
```

$capture1, $capture2 and $capture3 are available.

As with verifypositive, it is possible to disable a negative assertion without removing it. You do this by adding
another three `|||` and writing any message after the custom error message.

```
verifynegative: Record 5550|||Record 5550 is across county border - should not show|||Bug introduced with build 15221
verifynegative: Record 5550|||Record 5550 is across county border - should not show|||Bug introduced with build 15221
```

In addition, you can prepend a `fail fast!` flag to the start of the assertion to indicate that in the event the assertion fails,
WebImblaze should not retry the current test step.

```
verifynegative: fail fast!A critical error has occurred
verifynegative: fail fast!A critical error has occurred
```

<br />
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# WebImblaze 1.4.3
# WebImblaze 1.4.4

_UTF-8 is now well supported and the default, and gzip response content is now uncompressed automatically._

Expand Down
4 changes: 2 additions & 2 deletions selftest/substeps/gzip.test
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
step: Get a gzip page
url: https://varvy.com/pagespeed/enable-compression.html
url: https://www.internetmarketingninjas.com/tools/free-tools/pagespeed
addheader: Accept-Encoding: gzip
verifypositive: method of compressing
verifypositive: page speed
errormessage: Could not get a gzip page over SSL, fix any SSL errors first
4 changes: 4 additions & 0 deletions selftest/substeps/verifynegative.test
Original file line number Diff line number Diff line change
Expand Up @@ -27,3 +27,7 @@ step: Should be able to see response header
desc: Should fail
echo: headers
verifynegative: 100 OK|||This should fail since 100 OK is seen

step: Should have custom error message with dynamic text
echo: Error reference 123456.
verifynegative: Error reference ([^\.]+)|||Found an error with the reference $capture1
6 changes: 3 additions & 3 deletions selftest/verifynegative.test
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ step: verifynegative
varFEATURE: {TESTFILENAME}
shell: .\wi.pl -o selftest\output\{FEATURE}sub selftest\substeps\{FEATURE}.test
assertcount: Passed Negative Verification|||5|||Only Step 10 should have passed negative verifications
assertcount1: TEST STEP FAILED|||3|||Steps 20, 30 and 50 should fail
assertcount2: Failed Negative Verification|||7|||Should be failed negative verifications in steps 20, 30 and 50
assertcount1: TEST STEP FAILED|||4|||Steps 20, 30, 50 and 60 should fail
assertcount2: Failed Negative Verification|||8|||Should be failed negative verifications in steps 20, 30, 50 and 60
verifypositive: Should not find text but did
verifypositive1: Skipped Negative Verification 0 - Production Bug
verifypositive2: Found an error with the reference 123456
verifynegative: uninitialized value

18 changes: 8 additions & 10 deletions wi.pl
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
use strict;
use vars qw/ $VERSION /;

$VERSION = '1.4.3';
$VERSION = '1.4.4';

# This project is a fork of WebInject version 1.41, http://webinject.org/.
# Copyright 2004-2006 Corey Goldberg ([email protected])
Expand Down Expand Up @@ -2105,12 +2105,10 @@ sub _verify_verifypositive {
else {
$results_html .= qq|<span class="fail">Failed Positive Verification:</span>$_verifyparms[0]<br />\n|;
$results_xml .= qq| <success>false</success>\n|;
if ($_verifyparms[1]) { # is there a custom assertion failure message?
$results_html .= qq|<span class="fail">$_verifyparms[1]</span><br />\n|;
$results_xml .= ' <message>'._sub_xml_special($_verifyparms[1])."</message>\n";
}
colour_stdout('bold yellow', "Failed Positive Verification $_verify_number\n");
if ($_verifyparms[1]) {
if ($_verifyparms[1]) { # is there a custom assertion failure message?
$results_html .= qq|<span class="fail">$_verifyparms[1]</span><br />\n|;
$results_xml .= ' <message>'._sub_xml_special($_verifyparms[1])."</message>\n";
colour_stdout('bold yellow', "$_verifyparms[1] \n");
}
$failed_count++;
Expand Down Expand Up @@ -2151,12 +2149,12 @@ sub _verify_verifynegative {
if (uncoded() =~ m/$_verifyparms[0]/si) { # verify existence of string in response
$results_html .= qq|<span class="fail">Failed Negative Verification</span><br />\n|;
$results_xml .= qq| <success>false</success>\n|;
if ($_verifyparms[1]) {
$results_html .= qq|<span class="fail">$_verifyparms[1]</span><br />\n|;
$results_xml .= ' <message>'._sub_xml_special($_verifyparms[1])."</message>\n";
}
colour_stdout('bold yellow', "Failed Negative Verification $_verify_number\n");
if ($_verifyparms[1]) {
my $capture1 = $1; my $capture2 = $2; my $capture3 = $3;
$_verifyparms[1] =~ s/(\$\w+)/$1/eeg;
$results_html .= qq|<span class="fail">$_verifyparms[1]</span><br />\n|;
$results_xml .= ' <message>'._sub_xml_special($_verifyparms[1])."</message>\n";
colour_stdout('bold yellow', "$_verifyparms[1] \n");
}
$failed_count++;
Expand Down

0 comments on commit 48185ab

Please sign in to comment.