I'm moving this discussion to the dev mailing list.
Alex wrote on the generic mailing list:
> Hi Ansgar,
>
> My original thought was that the API in the Fail class is kind of
> ugly and it does not follow the fluent approach of the assertions,
> that's why I preferred not to expose it :D
>
> Once again, I'm over-worrying. Your argument for making the API
> public is the right one. If everybody can benefit from it, I have no
> objections :)
After thinking about my initial proposal for a while, I came to the
conclusion that it might be too liberal.
I think there are two different target audiences for the Fail classes' API:
1. Test author - should get a simple API and only use the unconditional
fail(...) methods from withing test code.
2. Assertion class author - should get reusable functions to check
frequent conditions like null, equals, etc.
I feel that it might be better to split the interfaces for these two
groups. If we offer Fail.failIf<Condition> to the casual test author, he
will probably start using failIf<Condition> instead of
assertThat(...).<Condition>, because then, there are two different APIs
do do the same thing: check that certain conditions hold. I'd like to
keep this separate.
One idea how to realize this is:
- introduce a dedicated java package for those classes intended to be
used by authors of custom assertion classes; the package name should
reflect the fact that it is intended to be used by assertion class
authors, not by test authors (maybe 'implementation', 'internal' --
certainly to be improved).
- extract all methods Fail.failIf<Condition> from class Fail and move
them into a new class which lives in this new package.
This way, we at least _guide_ both audiences. Of course, this does not
_guarantee_ that test authors don't call the conditional failIf<...>
methods, but a mindful test author will probably notice that he's doing
something wrong if he's calling into the library's internals.
Looking forward to feedback.
Kind regards
Ansgar
I think class "Formatting", "PrimitiveFail" are probably also
candidates. Maybe even "AssertExtension".
Kind regards
Ansgar
Yep, those are good ones. AssertExtension is kind of the exception, IMHO. I don't have a specific reason, just a gut-feeling that it should stay where it is.
BTW, probably "internal" would be a better name for the package, instead of "impl" :)
I'd like to settle the name. I feel "internal" is too strong, since the
package must be "a little bit public" for those users who want to extend
FEST Assertions.
If we could use "protected", that would be fine for me - but we can't,
since it's no valid Java identifier, but a reserved word.
Next best suggestion would be "confidential"...
Since I'm not a native speaker of English, but I feel that wording does
matter, I encourage you all to contribute your own suggestions and vote
for the one you like best.
Kind regards
Ansgar
Maybe we can just append "api" to "protected" and get a package name of:
org.fest.assertions.protectedapi
What do you think?
Kind regards
Ansgar
unfortunately I commited the relevant changes a few minutes before I
received your mail. But that's no problem. I'll do a reverse merge
tomorrow or so.
The public part of FEST Assertions (org.fest.assertions) would depend on
a "subpackage", that's true. As long as there are no circular
dependencies, I don't see any problems with this by now. I. e.,
org.fest.assertions may depend on classes in
org.fest.assertions.extensionapi, but not vice versa.
Of course we could also decide to use a different structure, with
org.fest.assertions as the public part of the library and say
org.fest.assertionimpl or similar containing the "extension api".
Kind regards
Ansgar
Hi Alex,
not a problem at all. The changes are not lost, I simply created an
experimental branch containing all the changes and reverted the trunk :-)
Kind regards
Ansgar