---
name: TestFailure
last_updated: 2026-11-16T22:19:01Z
inherits:
  - Object
type: class
memory_category: Instances
tags:
  - NotCreatable
  - NotReplicated
summary: "Details of one failed check in a test."
---

# Class: TestFailure

> Details of one failed check in a test.

## Description

A `TestFailure` describes one [TestCase:Check()](/docs/reference/engine/classes/TestCase.md) or
[TestCase:Require()](/docs/reference/engine/classes/TestCase.md) call that failed: its message, the expected and
actual values, and where in your code it was called. Get them from
[TestResult:GetFailures()](/docs/reference/engine/classes/TestResult.md).

A `TestFailure` isn't an [Instance](/docs/reference/engine/classes/Instance.md) and can't be parented.

```lua
for _, test in result:GetTests() do
	for _, failure in test:GetFailures() do
		local source = failure:GetSource()
		local location = if source then `{source:GetFullName()}:{failure.Line}` else "unknown"
		warn(`{test.TestId} at {location}: {failure.Message}`)
		warn(`  expected {failure:GetExpected()}, got {failure:GetActual()}`)
	end
end
```

## Properties

### Property: TestFailure.Line

```json
{
  "type": "int",
  "access": "ReadWrite",
  "security": {
    "read": "None",
    "write": "None"
  },
  "serialization": {
    "can_load": false,
    "can_save": true
  },
  "thread_safety": "ReadSafe",
  "category": "Data"
}
```

The line number, in the script returned by
[GetSource()](/docs/reference/engine/classes/TestFailure.md), of the failed
[TestCase:Check()](/docs/reference/engine/classes/TestCase.md) or [TestCase:Require()](/docs/reference/engine/classes/TestCase.md) call. If you call
[TestCase:Check()](/docs/reference/engine/classes/TestCase.md) from a helper function, this is the line inside
the helper.

### Property: TestFailure.Matcher

```json
{
  "type": "string",
  "access": "ReadWrite",
  "security": {
    "read": "None",
    "write": "None"
  },
  "serialization": {
    "can_load": false,
    "can_save": true
  },
  "thread_safety": "ReadSafe",
  "category": "Data"
}
```

The kind of comparison that failed. For [TestCase:Check()](/docs/reference/engine/classes/TestCase.md) and
[TestCase:Require()](/docs/reference/engine/classes/TestCase.md), it's `"equal"`.

### Property: TestFailure.Message

```json
{
  "type": "string",
  "access": "ReadWrite",
  "security": {
    "read": "None",
    "write": "None"
  },
  "serialization": {
    "can_load": false,
    "can_save": true
  },
  "thread_safety": "ReadSafe",
  "category": "Data"
}
```

The `message` passed to the failed [TestCase:Check()](/docs/reference/engine/classes/TestCase.md) or
[TestCase:Require()](/docs/reference/engine/classes/TestCase.md) call, or `Values are not equal` if it was
called without one.

### Property: TestFailure.StackTrace

```json
{
  "type": "string",
  "access": "ReadWrite",
  "security": {
    "read": "None",
    "write": "None"
  },
  "serialization": {
    "can_load": false,
    "can_save": true
  },
  "thread_safety": "ReadSafe",
  "category": "Data"
}
```

Reserved for future use. It's currently always empty for failures from
[TestCase:Check()](/docs/reference/engine/classes/TestCase.md) and [TestCase:Require()](/docs/reference/engine/classes/TestCase.md), so use
[GetSource()](/docs/reference/engine/classes/TestFailure.md) and
[Line](/docs/reference/engine/classes/TestFailure.md) to find where the check was called.

## Methods

### Method: TestFailure:GetActual

**Signature:** `TestFailure:GetActual(): Variant`

Returns the `actualValue` passed to the failed [TestCase:Check()](/docs/reference/engine/classes/TestCase.md) or
[TestCase:Require()](/docs/reference/engine/classes/TestCase.md) call, converted for display. Use it to show
what your code produced, not to compare against. Tables come back as new
tables that can differ from the original: a table that has an array part
loses its other keys, and in any other table every key becomes a string.
Instances come back as the same object, and threads as `nil`. A table that
can't be converted, such as one that contains itself, comes back as a
string naming its type, like `"<table>"`.

*Security: None · Thread Safety: Unsafe*

**Returns:** `Variant` — The `actualValue` passed to the failed check.

### Method: TestFailure:GetExpected

**Signature:** `TestFailure:GetExpected(): Variant`

Returns the `expectedValue` passed to the failed [TestCase:Check()](/docs/reference/engine/classes/TestCase.md)
or [TestCase:Require()](/docs/reference/engine/classes/TestCase.md) call, converted for display the same way as
[GetActual()](/docs/reference/engine/classes/TestFailure.md).

*Security: None · Thread Safety: Unsafe*

**Returns:** `Variant` — The `expectedValue` passed to the failed check.

### Method: TestFailure:GetSource

**Signature:** `TestFailure:GetSource(): Instance`

Returns the script that called the failed [TestCase:Check()](/docs/reference/engine/classes/TestCase.md) or
[TestCase:Require()](/docs/reference/engine/classes/TestCase.md). Returns `nil` if the script isn't known or no
longer exists. [Line](/docs/reference/engine/classes/TestFailure.md) is still set in that case.

*Security: None · Thread Safety: Unsafe*

**Returns:** `Instance` — The script, or `nil` if it isn't known or no longer exists.

## Inherited Members

### From [Object](/docs/reference/engine/classes/Object.md)

- **Property `ClassName`** (`string`): A read-only string representing the class this Object belongs to.
- **Property `className`** (`string`):  *(deprecated)*
- **Method `GetPropertyChangedSignal(property: string): RBXScriptSignal`**: Get an event that fires when a given property of the object changes.
- **Method `IsA(className: string): boolean`**: Returns true if an object's class matches or inherits from a given class.
- **Method `isA(className: string): boolean`**:  *(deprecated)*
- **Event `Changed`**: Fires immediately after a property of the object changes, with some