Open robstoll opened 5 years ago
Currently we use as...
in the API when we do an unreported transformation. As this is somewhat related to this issue I mentioned it here as well. Is it worth to make the distinction in the API as we need to explain it to the user. For instance, we have values
but asEntries
on Map. Not intuitive.
We could also provide a report option for feature extractors instead which would be available for every feature extraction. and set the default in a sense-full way per function. For instance, for Map<K,V>.entries
I would set the default to not show the extraction. Of course this only moves the problem to another spot.
Situation
We currently distinguish between feature extraction and a reporter subject change. They are very similar though. The main thing is a difference in reporting. Feature extraction uses an AssertionGroup with a FeatureAssertionGroupType where a subject change uses a descriptive assertion.
Following the comparison in reporting:
feature extraction:
subject change (assuming
get
is implemented as subject change)But... the check of the subject change does not even show up as it actually holds. So the error reporting looks like the following:
Which is confusing. => hence feature extraction makes more sense.
But why having a reported subject change then? It was mainly introduced because of
notToBeNull
where the followingwould look like the following with feature extraction:
vs. subject change
In terms of analysing the error the
is instance of: Int
seems redundant, as we can already see that from the first line. Thus I think it made sense to remove that. This is also true forisA
andtoThrow
. For instance:which looks like the following in reporting:
no need for an:
* is instance of: java.lang.IllegalArgumentException
in addition. However, if one had a reporter which reports all assertions (not only failing) then the* is instance of: java.lang.IllegalArgumentException
shows up.Problem
For instance, type transformations such as isA (or notToBeNull) are implemented via subject change. Hence
expect(Result.success(0)).isSuccess().toBe(1)
which includes kind of a type check as well, would logically be implemented with a subject changer as well. However, reporting would look like the following:which could be confusing because of the hidden
is: Success
. Or consider the EitherSpec:looks like the following:
which might be confusing as well without the
is a: Left
For this reasons I have decided that isSuccess should be implemented with a feature extraction (see https://github.com/robstoll/atrium/issues/203)
To be discussed
Shall we keep the distinction between subject change and feature extraction?