Atrium: shortcut fun `cause` for Throwable::getCause

Created on 3 Jul 2018  路  6Comments  路  Source: robstoll/atrium

Platform (JVM, JS and/or Android): jall

Code related feature

expect(expection).cause<NumberFormatException>().messageContains(...)

// instead of
expect(exception).feature(Throwable::cause) {
  isA<NumberFormatException>().messageContains(...)
}

// and
expect(expection).cause<NumberFormatException>() { 
  messageContains(...)
  cause.toBe(null)
}

// instead of

expect(exception).feature(Throwable::cause) {
    isA<NumberFormatException>() {
        messageContains(...)
        feature(Throwable::cause).toBe(null)
    }
}

Following the things you need to do:

lib

  • implement _cause in throwableAssertions (similar to _isThrowing in fun0Assertions.kt)

domain

  • add cause to ThrowableAssertions (see Fun0Assertions.isThrowing)
  • modify ThrowableAssertionsBuilder, delegate to throwableAssertions (see ListAssertionsBuilder as a guideline)
  • delegate implementation to robstoll-lib in ThrowableAssertionsImpl (see ListAssertionsImpl as a guideline)

api

  • provide a fun without argument and returns Expect<TSub> (see fun0Assertions.toThrow)
  • provide a fun which expects an assertionCreator-lambda and returns Expect<TSub> (see fun0Assertions.toThrow as well)
  • add @since 0.9.0 to both functions
  • extends ThrowableFeatureAssertionsSpec in specs-common

other

  • search for TODO #31 and simplify the code with the shortcut fun

Your first contribution?

  • Write a comment I'll work on this if you would like to take this issue over.
    This way we get the chance to revise the description in case things have changed in the meantime,
    we might give you additional hints and we can assign the task to you, so that others do not start as well.
  • See Your first code contribution for guidelines.
  • Do not hesitate to ask questions here or to contact us via Atrium's slack channel if you need help
    (Invite yourself in case you do not have an account yet).
good first issue help wanted

All 6 comments

I'll pick this one up :)

Heads up, I'll have this done this weekend. Tad hard to do this midweek with work. Sorry for the delay @robstoll :(

@javatarz no problem at all

@javatarz do you need help? Un-assigning you again, so that others could take over. Write here if you still work on it or if you would like to give it a go now

I'll work on this before starting #305

@robstoll wrote:

note that this one is not a good first issue, I would recommend you first implement

31 to get a bit more into Atrium and come back to this one afterwards

A good idea

implemented with 4c72123e

Was this page helpful?
0 / 5 - 0 ratings

Related issues

robstoll picture robstoll  路  3Comments

robstoll picture robstoll  路  4Comments

robstoll picture robstoll  路  4Comments

robstoll picture robstoll  路  6Comments

robstoll picture robstoll  路  3Comments