provide built-in negations for remaining assertions
This commit is contained in:
parent
3c3cdce66b
commit
0d5bb05c19
|
|
@ -46,7 +46,9 @@
|
|||
Only works properly with Ant 1.10.13 or later.
|
||||
</action>
|
||||
<action type="add">
|
||||
Add a new assertPropertyNotSet assertion.
|
||||
Add new assertNotEquals, assertPropertyNotSet,
|
||||
assertPropertyNotEquals, assertPropertyDoesntContain and
|
||||
assertReferenceIsNotSet assertions.
|
||||
</action>
|
||||
</release>
|
||||
<release version="1.4.1" date="2021-07-07">
|
||||
|
|
|
|||
|
|
@ -92,6 +92,53 @@
|
|||
actual="${foo}" casesensitive="false"/>
|
||||
</pre>
|
||||
|
||||
<h2><a name="assertNotEquals">assertNotEquals</a></h2>
|
||||
|
||||
<p>Asserts that its two arguments are not equal.</p>
|
||||
|
||||
<p><em>Since AntUnit 1.5</em></p>
|
||||
|
||||
<table border="1" cellpadding="2" cellspacing="0">
|
||||
<tr>
|
||||
<td valign="top"><b>Attribute</b></td>
|
||||
<td valign="top"><b>Description</b></td>
|
||||
<td align="center" valign="top"><b>Required</b></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td valign="top">notExpected</td>
|
||||
<td valign="top">First string to test.</td>
|
||||
<td valign="top" align="center">Yes</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td valign="top">actual</td>
|
||||
<td valign="top">Second string to test.</td>
|
||||
<td valign="top" align="center">Yes</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td valign="top">message</td>
|
||||
<td valign="top">Message for the exception if the condition
|
||||
doesn't hold true. Defaults to "Didn't expect
|
||||
'<em>notExpected</em>' to be '<em>actual</em>'".</td>
|
||||
<td align="center">No.</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td valign="top">casesensitive</td>
|
||||
<td valign="top">Perform a case sensitive comparision.
|
||||
Default is true.</td>
|
||||
<td valign="top" align="center">No</td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
<h3>Examples</h3>
|
||||
|
||||
<p>Make the build fail with the message "foo is bar" if the
|
||||
property foo doesn't hold the value bar regardless of case:</p>
|
||||
|
||||
<pre>
|
||||
<assertNotEquals message="foo is bar" notExpected="bar"
|
||||
actual="${foo}" casesensitive="false"/>
|
||||
</pre>
|
||||
|
||||
<h2><a name="assertPropertySet">assertPropertySet</a></h2>
|
||||
|
||||
<p>Asserts that a property has a value.</p>
|
||||
|
|
@ -125,6 +172,42 @@
|
|||
<assertPropertySet name="foo"/>
|
||||
</pre>
|
||||
|
||||
<h2><a name="assertPropertyNotSet">assertPropertyNotSet</a></h2>
|
||||
|
||||
<p><em>Since AntUnit 1.5</em></p>
|
||||
|
||||
<p>Asserts that a property hasn't got a value.</p>
|
||||
|
||||
<table border="1" cellpadding="2" cellspacing="0">
|
||||
<tr>
|
||||
<td valign="top"><b>Attribute</b></td>
|
||||
<td valign="top"><b>Description</b></td>
|
||||
<td align="center" valign="top"><b>Required</b></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td valign="top">name</td>
|
||||
<td valign="top">Name of the property.</td>
|
||||
<td valign="top" align="center">Yes</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td valign="top">message</td>
|
||||
<td valign="top">Message for the exception if the condition
|
||||
doesn't hold true. Defaults to "Didn't expect property
|
||||
'<em>name</em>' to be set but was '<em>actual value</em>'".</td>
|
||||
<td align="center">No.</td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
<h3>Examples</h3>
|
||||
|
||||
<p>Make the build fail with the message "Didn't expect property
|
||||
'foo' but was 'bar'" if the property foo is defined and has
|
||||
value bar:</p>
|
||||
|
||||
<pre>
|
||||
<assertPropertyNotSet name="foo"/>
|
||||
</pre>
|
||||
|
||||
<h2><a name="assertPropertyEquals">assertPropertyEquals</a></h2>
|
||||
|
||||
<p>Asserts that a given property is set and holds a certain
|
||||
|
|
@ -172,6 +255,53 @@
|
|||
name="foo" casesensitive="false"/>
|
||||
</pre>
|
||||
|
||||
<h2><a name="assertPropertyNotEquals">assertPropertyNotEquals</a></h2>
|
||||
|
||||
<p><em>Since AntUnit 1.5</em></p>
|
||||
|
||||
<p>Asserts that a given property is set but doesn't hold a certain
|
||||
value.</p>
|
||||
|
||||
<table border="1" cellpadding="2" cellspacing="0">
|
||||
<tr>
|
||||
<td valign="top"><b>Attribute</b></td>
|
||||
<td valign="top"><b>Description</b></td>
|
||||
<td align="center" valign="top"><b>Required</b></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td valign="top">name</td>
|
||||
<td valign="top">Name of the property.</td>
|
||||
<td valign="top" align="center">Yes</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td valign="top">value</td>
|
||||
<td valign="top">Not expected value.</td>
|
||||
<td valign="top" align="center">Yes</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td valign="top">message</td>
|
||||
<td valign="top">Message for the exception if the condition
|
||||
doesn't hold true. Defaults to "Didn't expect property '<em>name</em>' to have value '<em>value</em>'".</td>
|
||||
<td align="center">No.</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td valign="top">casesensitive</td>
|
||||
<td valign="top">Perform a case sensitive comparision.
|
||||
Default is true.</td>
|
||||
<td valign="top" align="center">No</td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
<h3>Examples</h3>
|
||||
|
||||
<p>Make the build fail with the message "foo is bar" if the
|
||||
property foo holds the value bar regardless of case:</p>
|
||||
|
||||
<pre>
|
||||
<assertPropertyNotEquals message="foo is bar" value="bar"
|
||||
name="foo" casesensitive="false"/>
|
||||
</pre>
|
||||
|
||||
<h2><a name="assertPropertyContains">assertPropertyContains</a></h2>
|
||||
|
||||
<p>Asserts that a given property is set and holds a certain
|
||||
|
|
@ -219,6 +349,55 @@
|
|||
name="foo" casesensitive="false"/>
|
||||
</pre>
|
||||
|
||||
<h2><a name="assertPropertyDoesntContain">assertPropertyDoesntContain</a></h2>
|
||||
|
||||
<p>Asserts that a given property is set and doesn't hold a certain
|
||||
value as substring.</p>
|
||||
|
||||
<p><em>Since AntUnit 1.5</em></p>
|
||||
|
||||
<table border="1" cellpadding="2" cellspacing="0">
|
||||
<tr>
|
||||
<td valign="top"><b>Attribute</b></td>
|
||||
<td valign="top"><b>Description</b></td>
|
||||
<td align="center" valign="top"><b>Required</b></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td valign="top">name</td>
|
||||
<td valign="top">Name of the property.</td>
|
||||
<td valign="top" align="center">Yes</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td valign="top">value</td>
|
||||
<td valign="top">Not expected substring value.</td>
|
||||
<td valign="top" align="center">Yes</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td valign="top">message</td>
|
||||
<td valign="top">Message for the exception if the condition
|
||||
doesn't hold true. Defaults to "Didn't expect property
|
||||
'<em>name</em>' to contain value '<em>value</em>' but was
|
||||
'<em>value of property name</em>'".</td>
|
||||
<td align="center">No.</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td valign="top">casesensitive</td>
|
||||
<td valign="top">Perform a case sensitive comparision.
|
||||
Default is true.</td>
|
||||
<td valign="top" align="center">No</td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
<h3>Examples</h3>
|
||||
|
||||
<p>Make the build fail with the message "foo contains bar" if the
|
||||
property foo contains the value bar regardless of case:</p>
|
||||
|
||||
<pre>
|
||||
<assertPropertyDoesntContain message="foo contains bar" value="bar"
|
||||
name="foo" casesensitive="false"/>
|
||||
</pre>
|
||||
|
||||
<h2><a name="assertFileExists">assertFileExists</a></h2>
|
||||
|
||||
<p>Asserts that a given file exists.</p>
|
||||
|
|
@ -688,6 +867,41 @@
|
|||
<assertReferenceSet name="foo"/>
|
||||
</pre>
|
||||
|
||||
<h2><a name="assertReferenceIsNotSet">assertReferenceIsNotSet</a></h2>
|
||||
|
||||
<p>Asserts that a reference hasn't got any value.</p>
|
||||
|
||||
<p><em>Since AntUnit 1.5</em></p>
|
||||
|
||||
<table border="1" cellpadding="2" cellspacing="0">
|
||||
<tr>
|
||||
<td valign="top"><b>Attribute</b></td>
|
||||
<td valign="top"><b>Description</b></td>
|
||||
<td align="center" valign="top"><b>Required</b></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td valign="top">refid</td>
|
||||
<td valign="top">Id of the reference.</td>
|
||||
<td valign="top" align="center">Yes</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td valign="top">message</td>
|
||||
<td valign="top">Message for the exception if the condition
|
||||
doesn't hold true. Defaults to "Didn't expect reference
|
||||
'<em>id</em>'".</td>
|
||||
<td align="center">No.</td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
<h3>Examples</h3>
|
||||
|
||||
<p>Make the build fail with the message "Didn't expect reference 'foo'"
|
||||
if the reference foo is defined:</p>
|
||||
|
||||
<pre>
|
||||
<assertReferenceIsNotSet name="foo"/>
|
||||
</pre>
|
||||
|
||||
<h2><a name="assertReferenceIsType">assertReferenceIsType</a></h2>
|
||||
|
||||
<p>Asserts that a reference has a value of a given type.</p>
|
||||
|
|
|
|||
|
|
@ -77,6 +77,22 @@ under the License.
|
|||
<au:assertEquals expected="bar" actual="BAR"/>
|
||||
</target>
|
||||
|
||||
<target name="assertNotEqualsPass1">
|
||||
<au:assertNotEquals notexpected="bar" actual="baz"/>
|
||||
</target>
|
||||
|
||||
<target name="assertNotEqualsPass2">
|
||||
<au:assertNotEquals notexpected="bar" actual="BAR"/>
|
||||
</target>
|
||||
|
||||
<target name="assertNotEqualsFail">
|
||||
<au:assertNotEquals notexpected="bar" actual="bar"/>
|
||||
</target>
|
||||
|
||||
<target name="assertNotEqualsCaseFail">
|
||||
<au:assertNotEquals notexpected="bar" actual="BAR" casesensitive="false"/>
|
||||
</target>
|
||||
|
||||
<target name="assertPropertySetPass">
|
||||
<property name="foo" value="bar"/>
|
||||
<au:assertPropertySet name="foo"/>
|
||||
|
|
@ -119,6 +135,30 @@ under the License.
|
|||
<au:assertPropertyEquals name="foo" value="BAR"/>
|
||||
</target>
|
||||
|
||||
<target name="assertPropertyNotEqualsPass1">
|
||||
<property name="foo" value="bar"/>
|
||||
<au:assertPropertyNotEquals name="foo" value="baz"/>
|
||||
</target>
|
||||
|
||||
<target name="assertPropertyNotEqualsPass2">
|
||||
<property name="foo" value="bar"/>
|
||||
<au:assertPropertyNotEquals name="foo" value="BAR"/>
|
||||
</target>
|
||||
|
||||
<target name="assertPropertyNotEqualsFail1">
|
||||
<au:assertPropertyNotEquals name="foo" value="bar"/>
|
||||
</target>
|
||||
|
||||
<target name="assertPropertyNotEqualsFail2">
|
||||
<property name="foo" value="bar"/>
|
||||
<au:assertPropertyNotEquals name="foo" value="bar"/>
|
||||
</target>
|
||||
|
||||
<target name="assertPropertyNotEqualsCaseFail">
|
||||
<property name="foo" value="bar"/>
|
||||
<au:assertPropertyNotEquals name="foo" value="BAR" casesensitive="false"/>
|
||||
</target>
|
||||
|
||||
<target name="assertPropertyContains">
|
||||
<property name="foo" value="bar"/>
|
||||
<au:assertPropertyContains name="foo" value="ba"/>
|
||||
|
|
@ -129,6 +169,16 @@ under the License.
|
|||
<au:assertPropertyContains name="foo" value="foo"/>
|
||||
</target>
|
||||
|
||||
<target name="assertPropertyDoesntContain">
|
||||
<property name="foo" value="bar"/>
|
||||
<au:assertPropertyDoesntContain name="foo" value="foo"/>
|
||||
</target>
|
||||
|
||||
<target name="assertPropertyDoesntContainFail">
|
||||
<property name="foo" value="bar"/>
|
||||
<au:assertPropertyDoesntContain name="foo" value="ba"/>
|
||||
</target>
|
||||
|
||||
<target name="assertFileExistsPass">
|
||||
<au:assertFileExists file="assert.xml"/>
|
||||
</target>
|
||||
|
|
@ -214,6 +264,15 @@ under the License.
|
|||
<au:assertReferenceSet refid="foo2"/>
|
||||
</target>
|
||||
|
||||
<target name="assertReferenceIsNotSetPass">
|
||||
<au:assertReferenceIsNotSet refid="foo3"/>
|
||||
</target>
|
||||
|
||||
<target name="assertReferenceIsNotSetFail">
|
||||
<path id="foo4"/>
|
||||
<au:assertReferenceIsNotSet refid="foo4"/>
|
||||
</target>
|
||||
|
||||
<target name="assertReferenceIsTypePass">
|
||||
<path id="foo3"/>
|
||||
<au:assertReferenceIsType refid="foo3" type="path"/>
|
||||
|
|
|
|||
|
|
@ -88,6 +88,22 @@ under the License.
|
|||
</sequential>
|
||||
</macrodef>
|
||||
|
||||
<macrodef name="assertNotEquals" backtrace="false">
|
||||
<attribute name="notExpected"/>
|
||||
<attribute name="actual"/>
|
||||
<attribute name="casesensitive" default="true"/>
|
||||
<attribute name="message"
|
||||
default="Didn't expect '@{notExpected}' to be '@{actual}'"/>
|
||||
<sequential>
|
||||
<au:fail message="@{message}">
|
||||
<not>
|
||||
<equals arg1="@{notExpected}" arg2="@{actual}"
|
||||
casesensitive="@{casesensitive}"/>
|
||||
</not>
|
||||
</au:fail>
|
||||
</sequential>
|
||||
</macrodef>
|
||||
|
||||
<macrodef name="assertPropertySet" backtrace="false">
|
||||
<attribute name="name"/>
|
||||
<attribute name="message"
|
||||
|
|
@ -102,7 +118,7 @@ under the License.
|
|||
<macrodef name="assertPropertyNotSet" backtrace="false">
|
||||
<attribute name="name"/>
|
||||
<attribute name="message"
|
||||
default="Expected property '@{name}' to not be set but was '${@{name}}'"/>
|
||||
default="Didn't expect property '@{name}' to be set but was '${@{name}}'"/>
|
||||
<sequential>
|
||||
<au:fail message="@{message}">
|
||||
<not>
|
||||
|
|
@ -125,6 +141,19 @@ under the License.
|
|||
</sequential>
|
||||
</macrodef>
|
||||
|
||||
<macrodef name="assertPropertyNotEquals" backtrace="false">
|
||||
<attribute name="name"/>
|
||||
<attribute name="value"/>
|
||||
<attribute name="casesensitive" default="true"/>
|
||||
<attribute name="message"
|
||||
default="Didn't expect property '@{name}' to have value '@{value}'"/>
|
||||
<sequential>
|
||||
<au:assertPropertySet message="@{message}" name="@{name}"/>
|
||||
<au:assertNotEquals message="@{message}" notexpected="@{value}"
|
||||
actual="${@{name}}" casesensitive="@{casesensitive}"/>
|
||||
</sequential>
|
||||
</macrodef>
|
||||
|
||||
<macrodef name="assertPropertyContains" backtrace="false">
|
||||
<attribute name="name"/>
|
||||
<attribute name="value"/>
|
||||
|
|
@ -140,6 +169,23 @@ under the License.
|
|||
</sequential>
|
||||
</macrodef>
|
||||
|
||||
<macrodef name="assertPropertyDoesntContain" backtrace="false">
|
||||
<attribute name="name"/>
|
||||
<attribute name="value"/>
|
||||
<attribute name="casesensitive" default="true"/>
|
||||
<attribute name="message"
|
||||
default="Didn't expect property '@{name}' to contain value '@{value}' but was '${@{name}}'"/>
|
||||
<sequential>
|
||||
<au:assertPropertySet message="@{message}" name="@{name}"/>
|
||||
<au:fail message="@{message}">
|
||||
<not>
|
||||
<contains string="${@{name}}" substring="@{value}"
|
||||
casesensitive="@{casesensitive}"/>
|
||||
</not>
|
||||
</au:fail>
|
||||
</sequential>
|
||||
</macrodef>
|
||||
|
||||
<macrodef name="assertFileExists" backtrace="false">
|
||||
<attribute name="file"/>
|
||||
<attribute name="message"
|
||||
|
|
@ -347,6 +393,19 @@ under the License.
|
|||
</sequential>
|
||||
</macrodef>
|
||||
|
||||
<macrodef name="assertReferenceIsNotSet" backtrace="false">
|
||||
<attribute name="refid"/>
|
||||
<attribute name="message"
|
||||
default="Didn't expect reference '@{refid}'"/>
|
||||
<sequential>
|
||||
<au:fail message="@{message}">
|
||||
<not>
|
||||
<isreference refid="@{refid}"/>
|
||||
</not>
|
||||
</au:fail>
|
||||
</sequential>
|
||||
</macrodef>
|
||||
|
||||
<macrodef name="assertReferenceIsType" backtrace="false">
|
||||
<attribute name="refid"/>
|
||||
<attribute name="type"/>
|
||||
|
|
|
|||
|
|
@ -49,6 +49,12 @@ public class AssertTest extends BuildFileTest {
|
|||
public void testEqualsCasePass() {
|
||||
testPass("assertEqualsCasePass");
|
||||
}
|
||||
public void testNotEqualsPass1() {
|
||||
testPass("assertNotEqualsPass1");
|
||||
}
|
||||
public void testNotEqualsPass2() {
|
||||
testPass("assertNotEqualsPass2");
|
||||
}
|
||||
public void testPropertySetPass() {
|
||||
testPass("assertPropertySetPass");
|
||||
}
|
||||
|
|
@ -61,6 +67,18 @@ public class AssertTest extends BuildFileTest {
|
|||
public void testPropertyEqualsCasePass() {
|
||||
testPass("assertPropertyEqualsCasePass");
|
||||
}
|
||||
public void testPropertyNotEqualsPass1() {
|
||||
testPass("assertPropertyNotEqualsPass1");
|
||||
}
|
||||
public void testPropertyNotEqualsPass2() {
|
||||
testPass("assertPropertyNotEqualsPass2");
|
||||
}
|
||||
public void testPropertyContains() {
|
||||
testPass("assertPropertyContains");
|
||||
}
|
||||
public void testPropertyDoesntContain() {
|
||||
testPass("assertPropertyDoesntContain");
|
||||
}
|
||||
public void testFileExistsPass() {
|
||||
testPass("assertFileExistsPass");
|
||||
}
|
||||
|
|
@ -88,6 +106,9 @@ public class AssertTest extends BuildFileTest {
|
|||
public void testReferenceSetPass() {
|
||||
testPass("assertReferenceSetPass");
|
||||
}
|
||||
public void testReferenceIsNotSetPass() {
|
||||
testPass("assertReferenceIsNotSetPass");
|
||||
}
|
||||
public void testReferenceIsTypePass() {
|
||||
testPass("assertReferenceIsTypePass");
|
||||
}
|
||||
|
|
@ -104,11 +125,17 @@ public class AssertTest extends BuildFileTest {
|
|||
public void testEqualsFail2() {
|
||||
testFail("assertEqualsFail2", "Expected 'bar' but was 'BAR'");
|
||||
}
|
||||
public void testNotEqualsFail() {
|
||||
testFail("assertNotEqualsFail", "Didn't expect 'bar' to be 'bar'");
|
||||
}
|
||||
public void testNotEqualsCaseFail() {
|
||||
testFail("assertNotEqualsCaseFail", "Didn't expect 'bar' to be 'BAR'");
|
||||
}
|
||||
public void testPropertySetFail() {
|
||||
testFail("assertPropertySetFail", "Expected property 'foo'");
|
||||
}
|
||||
public void testPropertyNotSetFail() {
|
||||
testFail("assertPropertyNotSetFail", "Expected property 'foo' to not be set but was 'bar'");
|
||||
testFail("assertPropertyNotSetFail", "Didn't expect property 'foo' to be set but was 'bar'");
|
||||
}
|
||||
public void testPropertyEqualsFail1() {
|
||||
testFail("assertPropertyEqualsFail1", "Expected property 'foo' to have value 'bar' but was '${foo}'");
|
||||
|
|
@ -119,12 +146,21 @@ public class AssertTest extends BuildFileTest {
|
|||
public void testPropertyEqualsFail3() {
|
||||
testFail("assertPropertyEqualsFail3", "Expected property 'foo' to have value 'BAR' but was 'bar'");
|
||||
}
|
||||
public void testPropertyContains() {
|
||||
testPass("assertPropertyContains");
|
||||
public void testPropertyNotEqualsFail1() {
|
||||
testFail("assertPropertyNotEqualsFail1", "Didn't expect property 'foo' to have value 'bar'");
|
||||
}
|
||||
public void testPropertyNotEqualsFail2() {
|
||||
testFail("assertPropertyNotEqualsFail2", "Didn't expect property 'foo' to have value 'bar'");
|
||||
}
|
||||
public void testPropertyNotEqualsCaseFail() {
|
||||
testFail("assertPropertyNotEqualsCaseFail", "Didn't expect property 'foo' to have value 'BAR'");
|
||||
}
|
||||
public void testPropertyContainsFail() {
|
||||
testFail("assertPropertyContainsFail", "Expected property 'foo' to contain value 'foo' but was 'bar'");
|
||||
}
|
||||
public void testPropertyDoesntContainFail() {
|
||||
testFail("assertPropertyDoesntContainFail", "Didn't expect property 'foo' to contain value 'ba' but was 'bar'");
|
||||
}
|
||||
public void testFileExistsFail() {
|
||||
testFail("assertFileExistsFail",
|
||||
"Expected file 'assert.txt' to exist");
|
||||
|
|
@ -160,6 +196,9 @@ public class AssertTest extends BuildFileTest {
|
|||
public void testReferenceSetFail() {
|
||||
testFail("assertReferenceSetFail", "Expected reference 'foo2'");
|
||||
}
|
||||
public void testReferenceIsNotSetFail() {
|
||||
testFail("assertReferenceIsNotSetFail", "Didn't expect reference 'foo4'");
|
||||
}
|
||||
public void testReferenceIsTypeFailNotSet() {
|
||||
testFail("assertReferenceIsTypeFailNotSet",
|
||||
"Expected reference 'foo4'");
|
||||
|
|
|
|||
Loading…
Reference in New Issue