Atrium: Any.isNoneOf/isNotIn

Created on 4 Oct 2019  路  13Comments  路  Source: robstoll/atrium

Platform (jvm, jdk8, js, android): all

Code related feature

expect(subject).isNoneOf(a, b, ...)
expect(subject).isNotIn(iterable)

//instead of
expect(subject).notToBe(a).notToBe(b)...
expect(subject).notToBe(iterable.next()).notToBe(iterable.next())...

However, reporting should not state multiple not to be (in case of a Reporter which shows all assertions) but reflect the intended grouping.
For instance:

expect(1).isNoneOf(1, 2, 3, 1)

should result in

expect: 1
* is none of:
   - 1

As we can see from the example, we don't have to check for unique values, that's the responsibility of the developer. Moreover, we want fail-fast behaviour (thus we don't see the second 1 in reporting).

Following the things you need to do:

atrium-logic

  • extend AnyAssertions with a function isNotIn which expects a List<T> (see existing functions as a guideline)
  • implement isNotIn in DefaultAnyAssertions use assertionBuilder.list..

    • add IS_NONE_OF("is none of") to DescriptionAnyAssertion for en_GB

    • add IS_NONE_OF("ist nicht") to DescriptionAnyAssertion for de_CH

      => use it for withDescriptionAndEmptyRepresentation

    • map the elements of List<T> to an assertionBuilder.representationOnly (similar to /domain/robstoll-lib/atrium-domain-robstoll-lib-common/src/main/kotlin/ch/tutteli/atrium/domain/robstoll/lib/creating/iterable/contains/creators/InAnyOrderOnlyAssertionCreator.kt => createExplanatoryGroupForMismatchesEtc) and use them for withAssertions

api-fluent-en_GB

  • provide a fun isNoneOf with signature (T, vararg T) (see mapAssertions.kt -> contains as a guideline)

    • add @since 0.9.0 to KDOC

  • provide a fun isNotIn with signature Iterable<T>

    • include a require that the Iterable.iterator.hasNext()

    • add @since 0.9.0 to KDOC

  • extend AnyAssertionsSpec in specs-common and extend it in atrium-api-fluent-en_GB-common/src/test

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 13 comments

I'll work on this.

Hi, is someone working on this, else I will take over

@DeMack, are you working on this? Else, I will start

@DeMack do you need help? un-assining you so that others can take over until I get a response

I'll work on this.

@gawarz let me know in case you need help

@gawarz unassigning you so that others can take over. Just leave a comment here in case you still work on it and I assign you again.

I'll work on this

@Jak-Sidious I just updated the description

@Jak-Sidious un-assigning you so that others can take over

I'll work on this

Hello. I won't be able to finish this issue. please unasign me

@robstoll can I work on this?

Was this page helpful?
0 / 5 - 0 ratings

Related issues

robstoll picture robstoll  路  3Comments

robstoll picture robstoll  路  6Comments

robstoll picture robstoll  路  6Comments

robstoll picture robstoll  路  4Comments

robstoll picture robstoll  路  7Comments