assertj / assertj/assertj-generator

For boolean properties, support "hasPropertyName(boolean expectedValue)"

Open
#125 1 comment 0 reactions 0 assignees View on GitHub
Dominant language
Java
Stars
72
Forks
47
Avg merge
1d 16h
Merged PRs (30d)
2

Description

Currently if a class has a boolean field / property (say **hideLegend,** the assertion generator produces two methods: **isHideLegend()** and **isNotHideLegend**. It would be really helpful to have an additional method **hasHideLegend(boolean expectedValue)**. To keep with the **BooleanAssert** pattern, this might become **hasHideLegendEqualTo(boolean)** and **hasHideLegendNotEqualTo(boolean)**. This is demonstrated by the example below:

```
private void testHelperMethod(MyAssertionClass instanceUnderTest, SomeInput input){
boolean expectedHasLegend = // some code that uses input to determine expected legend;
MyAssertionClassAssert assert = Assertions.assertThat(instanceUnderTest);

if (expectedHadLengeng)
assert.isHideLegend();
else
assert.isNotHideLegend();
}
```

The above could become:

```
private void testHelperMethod(MyAssertionClass instanceUnderTest, SomeInput input){
boolean expectedHasLegend = // some code that uses input to determine expected legend;
Assertions.assertThat(instanceUnderTest)
hasHideLegend(expectedHasLegend );
}
```

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.