Top AI Repos — open-source AI, indexed and scored
Top AI Repos tracks AI repositories on GitHub and answers two different questions about each one: is it moving right now, and would you bet a product on it.
Top AI Repos tracks AI repositories on GitHub and answers two different questions about each one: is it moving right now, and would you bet a product on it.
Hamcrest for Objective-C: Powerful, combinable, extensible matchers for verification
| Date | Stars |
|---|---|
| 2026-07-24 | 713 |
| 2026-07-25 | 713 |
| 2026-07-28 | 713 |
| 2026-07-30 | 713 |
| 2026-08-06 | 713 |
Today
— stars today
This week
— stars this week
This month
— stars this month
Momentum
0.0
growth rate 0.00%/day

# OCHamcrest
[](https://github.com/hamcrest/OCHamcrest/actions/workflows/build.yml)
[](https://coveralls.io/r/hamcrest/OCHamcrest)
[](https://swiftpackageindex.com/hamcrest/OCHamcrest)
[](https://github.com/Carthage/Carthage)
[](https://cocoapods.org/pods/OCHamcrest)
OCHamcrest is an Objective-C module providing:
* a library of "matcher" objects for declaring rules to check whether a given object matches those
rules.
* a framework for writing your own matchers.
Matchers can be combined to create flexible expressions of intent in tests.
They can also be used for other purposes, such as user input validation.
<!-- toc -->
## Contents
* [My First OCHamcrest Test](#my-first-ochamcrest-test)
* [Predefined Matchers](#predefined-matchers)
* [Object](#object)
* [Number](#number)
* [Text](#text)
* [Logical](#logical)
* [Collection](#collection)
* [Decorator](#decorator)
* [Syntactic Sugar](#syntactic-sugar)
* [Common Questions](#common-questions)
* [How Can I Assert on an Asynchronous Call?](#how-can-i-assert-on-an-asynchronous-call)
* [Can I Add Custom Matchers?](#can-i-add-custom-matchers)
* [What About Swift?](#what-about-swift)
* [How Do I Add OCHamcrest to My Project?](#how-do-i-add-ochamcrest-to-my-project)
* [Swift Package Manager](#swift-package-manager)
* [CocoaPods](#cocoapods)
* [Carthage](#carthage)
* [Prebuilt Framework](#prebuilt-framework)
* [Build Your Own](#build-your-own)
* [About the Author](#about-the-author)<!-- endToc -->
## My First OCHamcrest Test
We'll start by writing a very simple Xcode unit test, but instead of using XCTest's
`XCTAssertEqualObjects` function, we'll use OCHamcrest's `assertThat` construct and a predefined
matcher:
```obj-c
@import OCHamcrest;
@import XCTest;
@interface BiscuitTest : XCTestCase
@end
@implementation BiscuitTest
- (void)testEquals
{
Biscuit* theBiscuit = [[Biscuit alloc] initWithName:@"Ginger"];
Biscuit* myBiscuit = [[Biscuit alloc] initWithName:@"Ginger"];
assertThat(theBiscuit, equalTo(myBiscuit));
}
@end
```
The `assertThat` function is a stylized sentence for making a test assertion. In this example, the
subject of the assertion is the object `theBiscuit`, which is the first method parameter. The second
method parameter is a matcher for `Biscuit` objects, here a matcher that checks one object is equal
to another using the `-isEqual:` method. The test passes since the `Biscuit` class defines an
`-isEqual:` method.
OCHamcrest's functions are actually declared with an "HC_" package prefix (such as `HC_assertThat`
and `HC_equalTo`) to avoid name clashes. To make test writing faster and test code more legible,
optional short syntax is provided by default. For example, instead of writing `HC_assertThat`,
simply write `assertThat`.
## Predefined Matchers
OCHamcrest comes with a library of useful matchers:
### Object
* `conformsTo` - match object that conforms to protocol
* `equalTo` - match equal object
* `hasDescription` - match object's `-description`
* `hasProperty` - match return value of method with given name
* `instanceOf` - match object type
* `isA` - match object type precisely, no subclasses
* `nilValue`, `notNilValue` - match `nil`, or not `nil`
* `sameInstance` - match same object
* `throwsException` - match block that throws an exception
* HCArgumentCaptor - match anything, Excerpt of 11,079 characters
Read on GitHub1.2k
13
@actions
12
6
5
4
2
1
1
1
1
1
1
Santiago Castro · @Netflix · United States
1
1
1
1
1
1
Would you bet a product on this? Bounded 0–100 and slow moving.
matched fp:e910dd86e6ca60c3, topic:testing