This is an automated email from the ASF dual-hosted git repository.

asf-gitbox-commits pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/ant-antlibs-antunit.git


The following commit(s) were added to refs/heads/master by this push:
     new d00b9e0  add a assertPropertyNotSet assertion
d00b9e0 is described below

commit d00b9e083327fb4ff1fbdf224f2ee994643f6be3
Author: Stefan Bodewig <[email protected]>
AuthorDate: Thu May 14 21:35:02 2026 +0200

    add a assertPropertyNotSet assertion
---
 changes.xml                                            |  3 +++
 src/etc/testcases/assert.xml                           |  9 +++++++++
 src/main/org/apache/ant/antunit/antlib.xml             | 13 +++++++++++++
 src/tests/junit/org/apache/ant/antunit/AssertTest.java |  6 ++++++
 4 files changed, 31 insertions(+)

diff --git a/changes.xml b/changes.xml
index a100c2b..ad29a93 100644
--- a/changes.xml
+++ b/changes.xml
@@ -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">
diff --git a/src/etc/testcases/assert.xml b/src/etc/testcases/assert.xml
index 8859b3d..ca33ada 100644
--- a/src/etc/testcases/assert.xml
+++ b/src/etc/testcases/assert.xml
@@ -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"/>
diff --git a/src/main/org/apache/ant/antunit/antlib.xml 
b/src/main/org/apache/ant/antunit/antlib.xml
index 87327bf..115387c 100644
--- a/src/main/org/apache/ant/antunit/antlib.xml
+++ b/src/main/org/apache/ant/antunit/antlib.xml
@@ -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"/>
diff --git a/src/tests/junit/org/apache/ant/antunit/AssertTest.java 
b/src/tests/junit/org/apache/ant/antunit/AssertTest.java
index 9e2ac1b..d56b010 100644
--- a/src/tests/junit/org/apache/ant/antunit/AssertTest.java
+++ b/src/tests/junit/org/apache/ant/antunit/AssertTest.java
@@ -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}'");
     }

Reply via email to