Coder Social home page Coder Social logo

robfletcher / strikt Goto Github PK

View Code? Open in Web Editor NEW
543.0 5.0 58.0 2.83 MB

An assertion library for Kotlin

Home Page: https://strikt.io/

License: Apache License 2.0

Kotlin 99.01% Java 0.34% Shell 0.20% SCSS 0.45%
kotlin assertions testing test fluent-api assert

strikt's Issues

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

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()

Name the project

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

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.

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)

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

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.

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.

More robust reporting

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

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

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.