Code Monkey home page Code Monkey logo

strikt's Introduction

Strikt

Strikt is an assertion library for Kotlin intended for use with a test runner such as JUnit, Minutest, Spek, or KotlinTest.

Strikt uses a fluent assertion style similar to AssertJ but leverages Kotlin's type system and extension functions rather than needing a complex hierarchy of assertion builder classes.

Strikt is under development, but 100% usable. The API may change until a version 1.0 is released. Any suggestions, issue reports, contributions, or feedback are very welcome.

Installation

Strikt is available from Maven Central.

repositories {
  mavenCentral()
}

dependencies {
  testImplementation("io.strikt:strikt-core:<version>")
}

See the button below or releases/latest for the current version number.

Additional Libraries

Strikt has the following additional libraries:

  • strikt-arrow -- supports data types from the Arrow functional programming library.
  • strikt-jackson -- supports the Jackson JSON library.
  • strikt-jvm -- supports types from the Java SDK.
  • strikt-mockk -- supports types from the MockK library.
  • strikt-protobuf -- supports Protobuf / gRPC.
  • strikt-spring -- supports the Spring Framework.

Versions are synchronized with the core Strikt library.

To install additional libraries include dependencies in your Gradle build. For example:

dependencies {
  testImplementation("io.strikt:strikt-jvm:<version>")
}

Bill of Materials

Strikt supplies a BOM that is useful for aligning versions when using more than one Strikt module.

dependencies {
  // BOM dependency
  testImplementation(platform("io.strikt:strikt-bom:<version>"))

  // Versions can be omitted as they are supplied by the BOM
  testImplementation("io.strikt:strikt-jackson")
  testImplementation("io.strikt:strikt-jvm")
  testImplementation("io.strikt:strikt-spring")
}

Using Strikt

Please see the project documentation and API docs.

Community

Join the #strikt channel on the Kotlin Slack.

Follow @stri_kt on Twitter for updates and release notifications.

Maven Central GitHub Release Date license GitHub issues GitHub Workflow Status (branch) GitHub top language Twitter Follow

strikt's People

Contributors

abendt avatar adrielcafe avatar christian-draeger avatar christophsturm avatar cjbrooks12 avatar daniel-rusu avatar danielthomas avatar dump247 avatar eskatos avatar gavinray97 avatar hubertbraszko avatar ilaborie avatar jakub-bochenski avatar lenguyenthanh avatar lnhrdt avatar lucasvsme avatar mkobit avatar monosoul avatar qoomon avatar r0adkll avatar ramazanyapparov avatar reevn avatar robd avatar robfletcher avatar sandjelkovic avatar segunfamisa avatar sksamuel avatar tristanlins avatar vbsteven avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

strikt's Issues

Name the project

“Honeydew” has been suggested. I quite like it even though I’m allergic to the fruit.

Allow providing custom error messages

On assertion fails, it would be really useful to have custom error messages prepended to the regular output.

Currently, a workaround is using subjectDescription:

expect("loading view should be gone: %s", loadingView.visibility).isEqualTo(View.GONE)

Here's what other libraries do:

// Google-truth
assertWithMessage("My custom message on failure")
  .that(view)
  .isNotNull();
// AssertJ
assertThat(view)
  .as("My custom message)
  .isNotNull()

Format subject with a description

  • Automatically populate property names when using map
  • Type-aware format:
    • Quote strings
    • Transform ()->Unit to something representative
    • Canonical class name
    • Recurse for collections
  • Highlight type when toString of actual and subject are the same #19
  • Nest results for block-style expect

More robust reporting

Allow reporting to write in a variety of formats. Colorized ANSI text for a start.

Create GH pages docs

I'd like proper multi-page docs with the Dokka-generated API docs properly integrated. They should get pushed to gh-pages by Gradle as part of the release process.

Disambiguate forms of `expect`

fun <T> expect(subjectDescription: String, subject: T): Assertion<T>
and
fun <T> expect(subject: T, block: Assertion<T>.() -> Unit): Assertion<T>
are indistinguishable to the compiler when using a String subject.

Is it an assertion on a ()->* subject with a description or a block assertion on a String?

This needs to not happen.

Include API docs on documentation site

Dokka can generate markdown and it's possible to include it in the Mkdocs generated site but:

  • You have to list all the files in the mkdocs.yml
  • The styling needs some work for it to be legible

Add extensions for Android

Adding extensions for Android will allow some often-used assertions to be shorter and more idiomatic. For example, we could have:

expect(view).isGone()

instead of

expect(view.getVisibility()).isEqualTo(View.GONE)

A good starting point for these might be assertj-android: https://github.com/square/assertj-android

More assertion functions

Additional assertions should be added to the strikt.assertions package.

Some ideas:

CharSequence

  • contains(String)
  • isNumeric()
  • isEqualToIgnoringCase(String)

Collection

  • map to sub-sequence

Map

  • isEmpty()
  • contains(K, V)
  • containsKey(K)

Data classes / POJOs

  • isIndenticalTo(T) (property-by-property equality)
  • propertyEquals(Any) (shortcut for map(KProperty0).isEqualTo(expected))

Arrays

  • contentEquals(T) (delegate to same method on Kotlin's Array type)

Standard mapping properties / methods

Add some useful extension properties and methods for common uses of Assertion<T>.map(()->R): Assertion<R>

  • Assertion<Any?>.toString
  • Assertion<Collection<E>>.first() etc.
  • Assertion<List<E>>.get(IntRange) etc.

Report skipped assertions

If an assertion is not evaluated because the chain before it broke it would be nice to see that in the output.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.