add a assertPropertyNotSet assertion

This commit is contained in:
Stefan Bodewig 2026-05-14 21:35:02 +02:00
parent 1d98715cab
commit d00b9e0833
No known key found for this signature in database
GPG Key ID: 23738DFD7C40DE43
4 changed files with 31 additions and 0 deletions

View File

@ -45,6 +45,9 @@
Only works properly with Ant 1.10.13 or later.
</action>
<action type="add">
Add a new assertPropertyNotSet assertion.
</action>
</release>
<release version="1.4.1" date="2021-07-07">
<action type="fix" issue="65315">

View File

@ -86,6 +86,15 @@ under the License.
<au:assertPropertySet name="foo"/>
</target>
<target name="assertPropertyNotSetPass">
<au:assertPropertyNotSet name="foo"/>
</target>
<target name="assertPropertyNotSetFail">
<property name="foo" value="bar"/>
<au:assertPropertyNotSet name="foo"/>
</target>
<target name="assertPropertyEqualsPass">
<property name="foo" value="bar"/>
<au:assertPropertyEquals name="foo" value="bar"/>

View File

@ -99,6 +99,19 @@ under the License.
</sequential>
</macrodef>
<macrodef name="assertPropertyNotSet" backtrace="false">
<attribute name="name"/>
<attribute name="message"
default="Expected property '@{name}' to not be set but was '${@{name}}'"/>
<sequential>
<au:fail message="@{message}">
<not>
<isset property="@{name}"/>
</not>
</au:fail>
</sequential>
</macrodef>
<macrodef name="assertPropertyEquals" backtrace="false">
<attribute name="name"/>
<attribute name="value"/>

View File

@ -52,6 +52,9 @@ public class AssertTest extends BuildFileTest {
public void testPropertySetPass() {
testPass("assertPropertySetPass");
}
public void testPropertyNotSetPass() {
testPass("assertPropertyNotSetPass");
}
public void testPropertyEqualsPass() {
testPass("assertPropertyEqualsPass");
}
@ -104,6 +107,9 @@ public class AssertTest extends BuildFileTest {
public void testPropertySetFail() {
testFail("assertPropertySetFail", "Expected property 'foo'");
}
public void testPropertyNotSetFail() {
testFail("assertPropertyNotSetFail", "Expected property 'foo' to not be set but was 'bar'");
}
public void testPropertyEqualsFail1() {
testFail("assertPropertyEqualsFail1", "Expected property 'foo' to have value 'bar' but was '${foo}'");
}