---
schema_version: "1"
id: cf2739636fafbfbb365eb40f05c4ac118b9c907c45bd218dff43d3037739aa3a
title: MUnit Comparable Matchers Reference
collection: mulesoft
version: current
locale: en-us
portal_url: https://docs.salesforce.com/mulesoft/current/en-us/munit/latest/comparable-matchers-reference.md
canonical_url: https://docs.mulesoft.com/munit/latest/comparable-matchers-reference
source_site: docs.mulesoft.com
content_type: documentation
content_hash: f8da86aace0be1da4c87d94424f6c5f02f7260601eadfd2f021eb5db71f60495
description: MuleSoft Documentation Site
release: "3.7"
latest: true
---
---
product: MUnit
version: 3.7
is-latest-version: true
---

# MUnit Comparable Matchers Reference

> For the full documentation index, see: https://docs.mulesoft.com/llms.txt

![logo acb active](/mulesoft/current/en-us/_/img/icons/anypoint-code-builder.svg "Anypoint Code Builder")Anypoint Code
Builder

![logo studio active](/mulesoft/current/en-us/_/img/icons/studio.svg "Anypoint Studio")Anypoint Studio

MUnit Comparable matchers are matcher functions that assert comparison conditions on values during a
MUnit test. Use them with the Assert That processor to check if a value is greater than, less than,
equal to, or close to an expected value.

> [!NOTE] `Comparable` is a DataWeave type that represents all the types that can be compared to
> each other.  
> Allowed primitives are String, Number, Boolean, DateTime, LocalDateTime, LocalTime, Time, and
> TimeZone that you can pass any primitive value such as an integer or a date.

## greaterThan(Comparable)

Checks that the expression is greater than the specified value.

Example

```xml
<munit-tools:assert-that
expression="#[payload]"
is="#[MunitTools::greaterThan(|2017-08-09|)]"/>
```

Example

```xml
<munit-tools:assert-that
expression="#[payload]"
is="#[MunitTools::greaterThan(20)]"/>
```

## greaterThanOrEqualTo(Comparable)

Checks that the expression is greater than or equal to the specified value.

Example

```xml
<munit-tools:assert-that
expression="#[payload]"
is="#[MunitTools::greaterThanOrEqualTo(20)]"/>
```

Example

```xml
<munit-tools:assert-that
expression="#[payload]"
is="#[MunitTools::greaterThanOrEqualTo(|2017-08-09|)]"/>
```

## lessThan(Comparable)

Checks that the expression is less than the specified value.

Example

```xml
<munit-tools:assert-that
expression="#[payload]"
is="#[MunitTools::lessThan(20)]"/>
```

Example

```xml
<munit-tools:assert-that
expression="#[payload]"
is="#[MunitTools::lessThan(|2017-08-09|)]"/>
```

## lessThanOrEqualTo(Comparable)

Checks that the expression is less than or equal to the specified value.

Example

```xml
<munit-tools:assert-that
expression="#[payload]"
is="#[MunitTools::lessThanOrEqualTo(20)]"/>
```

Example

```xml
<munit-tools:assert-that
expression="#[payload]"
is="#[MunitTools::lessThanOrEqualTo(|2017-08-09|)]"/>
```

## closeTo(Number, Number)

Checks that the expression is close to the first number, using the second number as a delta value.  
In other words, checks that the expression belongs to the range defined by the first number +/- the
second number.

Example

```xml
<munit-tools:assert-that
expression="#[payload]"
is="#[MunitTools::closeTo(1, 0.01)]"/>

<!--
  This evaluates if the expression is between 0.99 (1 - 0.01) and 1.01 (1 + 0.01)
-->
```

## equalTo(Object)

Checks that the expression is equal to a specific value.

Example

```xml
<munit-tools:assert-that
expression="#[payload]"
is="#[MunitTools::equalTo(0)]"/>
```

Example

```xml
<munit-tools:assert-that
expression="#[payload]"
is="#[MunitTools::equalTo('example')]"/>
```

This matcher also accepts Dataweave objects.

Example

```xml
<munit-tools:assert-that
expression="#[{example1: 1 , example2: 2}]"
is="#[MunitTools::equalTo({example1: 1 , example2: 2})]"/>
```

The matcher validates that the keys and their respective values are the same.  
The order in the matcher must be the same as the one in the expression or the assertion fails.

Example

```xml
<munit-tools:assert-that
expression="#[{example1: 1 , example2: 2}]"
is="#[MunitTools::equalTo({example2: 2 , example1: 1})]"/>

<!-- This assertion fails -->
```

Example

```xml
<munit-tools:assert-that
expression="#[[1, 2, 3]]"
is="#[MunitTools::equalTo([3, 2, 1])]"/>

<!-- This assertion fails -->
```

## See Also

- [DataWeave Comparable Type](https://docs.mulesoft.com/dataweave/latest/dataweave-types#dw_type_comparable)

- [MUnit Matchers](https://docs.mulesoft.com/munit/latest/munit-matchers)

- [Core Matchers Reference](https://docs.mulesoft.com/munit/latest/core-matchers-reference)

- [String Matchers Reference](https://docs.mulesoft.com/munit/latest/string-matchers-reference)

- [Iterable and Map Matchers Reference](https://docs.mulesoft.com/munit/latest/iterable-map-matchers-reference)
