cactoos: Tests of cacctoos is not oop
Right now tests use alot of static function from matchers, Maybe they should be more oop style, like let’s take this example
@Test
public void iteratesEmptyList() {
final List<String> list = new LinkedList<>();
MatcherAssert.assertThat(
"Can't iterate a list",
new And(
new Mapped<String, Scalar<Boolean>>(
new FuncOf<>(list::add, () -> true), Collections.emptyList()
)
),
new ScalarHasValue<>(
Matchers.allOf(
Matchers.equalTo(true),
new MatcherOf<>(
value -> {
return list.isEmpty();
}
)
)
)
);
}
in oop style this would be
@Test
public void iteratesEmptyList() {
final List<String> list = new LinkedList<>();
MatcherAssert.assertThat(
"Can't iterate a list",
new And(
new Mapped<String, Scalar<Boolean>>(
new FuncOf<>(list::add, () -> true), Collections.emptyList()
)
),
new ScalarHasValue<>(
new AllOf<Boolean>(
new IterableOf<>(
new IsEqual<>(true),
new MatcherOf<>(
value -> {
return list.isEmpty();
}
)
)
)
)
);
}
or this is overkill?
About this issue
- Original URL
- State: closed
- Created 6 years ago
- Reactions: 2
- Comments: 44 (11 by maintainers)
Commits related to this issue
- Tests are more OO #588 — committed to victornoel/cactoos by victornoel 6 years ago
- Tests are more OO #588 — committed to victornoel/cactoos by victornoel 6 years ago
@yegor256 there is plugin for maven forbidden-apis
Sample configuration: add this profile to pom.xml
create file
./src/test/resources/org/cactoos/forbidden.txtwith contentrun maven goal
forbiddenapis:testCheck, and you wold have something similar to thisplugin also includes some bundled signatures for jdk unsafe methods, but for this examaple i excluded them
also it can match specific methods, link to example