Atrium: shortcut for Iterable<E: Comparable<E>>.min()

Created on 2 Oct 2019  路  11Comments  路  Source: robstoll/atrium

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

Code related feature

expect(listOf(1,2,3)).min().toBe(3) 
expect(listOf(1,2,3)).min {
   isGreaterThan(3)  
   isLessThan(5)
}

//instead of

expect(listOf(1,2,3)).feature { f(it::min) }.notToBeNull().toBe(3)
expect(listOf(1,2,3)).feature({ f(it::min) }) {
  notToBeNull {
    isGreaterThan(3)  
    isLessThan(5)
  }
}

However, in reporting we want to see the following in case there aren't any elements in the iterable:

expect: List()
* min: !! cannot be determined, empty Iterable
  >> to be: 3

Following the things you need to do:

domain

  • extend IterableAssertions with a function min (see ListAssertions.get as a guideline)
  • modify IterableAssertionsBuilder, delegate to iterableAssertions (see other functions as a guideline)
  • delegate implementation to robstoll-lib in IterableAssertionsImpl (see other functions as a guideline)

lib

  • implement _min in iterableAssertions by using ExpectImpl.feature.extractor (see listAssertions -> _get) => use the following as failure representation

    • add NO_ELEMENTS("鉂椻潡 cannot be determined, empty Iterable") to DescriptionIterable of en_GB

    • add NO_ELEMENTS("鉂椻潡 kann nicht eruiert werden, leeres Iterable") to DescriptionIterable of de_CH

api (only fluent-en_GB)

  • provide a val which returns Expect (see collectionAssertions.kt as a guideline)
  • provide a fun which expects an assertionCreator-lambda and returns Expect where T : Iterable<E>, E : Comparable<E> (see collectionAssertions.kt as a guideline)
  • augment IterableFeatureAssertionsSpec with min in specs-common (see for instance CollectionFeatureAssertionsSpec) 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 hacktoberfest help wanted

All 11 comments

I'll work on this

is someone still working on this? else I will start

@ntedgi please answer if you are. @piyushmor feel free to start, in the worst case you both do the same work => assigned you

sorry didn't manged to finish that yet

@ntedgi did you already start? If so, you could still push your changes as WIP PR and @piyushmor could take over from there. Up to you two

Would totally like to take over

@robstoll Kindly check the PR again. If the changes are fine. I have issues in adding the Feature Test

What issues? I'll take a look now

I took size as a reference, which returns an Expect<Iterable<E>> whereas get returns an Expect<E>. Not sure why the test expects a different behavior. will commit the test even if compilation breaks once you confirm what i have done so far is fine.

Please push the code as well, hard to tell what you mean without further context (I reviewed your code)

Implemented by da897cb2322872452deb0e22ef875c16043a3b9d

Was this page helpful?
0 / 5 - 0 ratings

Related issues

robstoll picture robstoll  路  4Comments

robstoll picture robstoll  路  6Comments

robstoll picture robstoll  路  7Comments

robstoll picture robstoll  路  5Comments

robstoll picture robstoll  路  3Comments