All Projects → npryce → Hamkrest

npryce / Hamkrest

Licence: apache-2.0
Hamcrest for Kotlin

Programming Languages

kotlin
9241 projects

Projects that are alternatives of or similar to Hamkrest

Karate
Test Automation Made Simple
Stars: ✭ 5,497 (+1634.07%)
Mutual labels:  test-automation, assertions
Zunit
A powerful testing framework for ZSH projects
Stars: ✭ 140 (-55.84%)
Mutual labels:  test-automation, assertions
karate
Test Automation Made Simple
Stars: ✭ 6,384 (+1913.88%)
Mutual labels:  assertions, test-automation
tropic
🍍 Test Runner Library
Stars: ✭ 29 (-90.85%)
Mutual labels:  test-automation
jdbdt
JDBDT: Java Database Delta Testing
Stars: ✭ 12 (-96.21%)
Mutual labels:  test-automation
Robotframework Appiumlibrary
AppiumLibrary is an appium testing library for RobotFramework
Stars: ✭ 259 (-18.3%)
Mutual labels:  test-automation
Nut.js
Native UI testing / controlling with node
Stars: ✭ 309 (-2.52%)
Mutual labels:  test-automation
apitest
Apitest is declarative api testing tool with JSON-like DSL.
Stars: ✭ 88 (-72.24%)
Mutual labels:  test-automation
Qt4a
QTA driver for Android app
Stars: ✭ 297 (-6.31%)
Mutual labels:  test-automation
zmock
zmock--http接口的mock平台
Stars: ✭ 98 (-69.09%)
Mutual labels:  test-automation
xRetry
Retry running tests via Xunit and Specflow
Stars: ✭ 15 (-95.27%)
Mutual labels:  test-automation
atata-kendoui
A set of Atata components for Kendo UI
Stars: ✭ 17 (-94.64%)
Mutual labels:  test-automation
Hadoop Mini Clusters
hadoop-mini-clusters provides an easy way to test Hadoop projects directly in your IDE
Stars: ✭ 265 (-16.4%)
Mutual labels:  test-automation
gauge-ts
Typescript language plugin for Gauge
Stars: ✭ 20 (-93.69%)
Mutual labels:  test-automation
Wpt
Test suites for Web platform specs — including WHATWG, W3C, and others
Stars: ✭ 3,573 (+1027.13%)
Mutual labels:  test-automation
DeepfakeHTTP
DeepfakeHTTP is a web server that uses HTTP dumps as a source for responses.
Stars: ✭ 373 (+17.67%)
Mutual labels:  test-automation
Tester
Tester: enjoyable unit testing in PHP with code coverage reporter. 🍏🍏🍎🍏
Stars: ✭ 281 (-11.36%)
Mutual labels:  assertions
arquillian-container-was
Arquillian WebSphere Containers
Stars: ✭ 18 (-94.32%)
Mutual labels:  test-automation
sbml-test-suite
The SBML Test Suite is a conformance testing system. It allows developers and users to test the degree and correctness of the SBML support provided in a software package.
Stars: ✭ 21 (-93.38%)
Mutual labels:  test-automation
Awesome Robotframework
A curated list of awesome Robot Framework resources and libraries
Stars: ✭ 257 (-18.93%)
Mutual labels:  test-automation

HamKrest - Hamcrest for Kotlin

A reimplementation of Hamcrest to take advantage of Kotlin language features.

Kotlin Build Status Maven Central

Note: as of version 1.4.0.0, you must add kotlin-reflect to the classpath to use HamKrest's reflective features.

When working in Kotlin, Hamkrest provides these benefits over using the Java Hamcrest library:

  • Kotlin's type system means that developers don't have to worry about getting the variance of generic signatures right. Variance is defined on the abstract Matcher type and Kotlin makes sure composition and subtyping work together the way you expect.

  • Syntactic sugar. You can negate a matcher with the ! operator and compose matchers with infix and and or functions:

    import com.natpryce.hamkrest.assertion.assert
          
    ...
          
    assertThat("xyzzy", startsWith("x") and endsWith("y") and !containsSubstring("a"))
    
  • Easier to extend. You can convert named unary predicates into matchers.

    val isBlank = Matcher(String::isBlank)
    
    assertThat(input, isBlank)
    

    As a shortcut, you can pass named functions to the assertThat, and, or and many other functions that take a matcher.

    assertThat(input, String::isBlank)
    

    You can also convert a named binary predicate and the second argument to a matcher for first argument, which works well for extension methods.

    fun String.hasLength(n: Int): Boolean = this.length == n
    
    val isTheRightLength = Matcher(String::hasLength, 8)
    
    assertThat(secretCode, isTheRightLength)
    

    You can use function and property references to match features of a value:

    val isLongEnough = has(String::length, greaterThan(8))
    
    assertThat(password, isLongEnough)
    

    All of these shortcuts produce good, human-readable diagnostics.

    You can customise how diagnostics are generated by creating a project-specific assert object.

More documentation

More detailed documentation of specific library features is in the docs/ directory.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].