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

Open
#125 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
4/5
Estimated time
3-5 days
Newbie friendliness
35/100
Issue type
Feature
Clarity
Mostly clear
Activity status
Stale
Tech stack
java
Domain
testing, tooling

Research direction

Start by locating the assertion generator logic that creates methods for boolean properties, then compare the requested API with the existing BooleanAssert pattern. Decide whether the generated method should be hasHideLegend(boolean) or equality-specific variants, and add coverage showing the generated assertion handles both expected boolean values.

Written by the indexing model from the issue text.

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 );
}
Dominant language
Java
Stars
72
Forks
47
PR merge metrics
No merged PRs in 30d

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from assertj/assertj-generator

All issues in assertj/assertj-generator

Similar issues

More Java issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.