Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Test coverage for Data Classes #283

Open
wants to merge 5 commits into
base: upgrade-jdk11
Choose a base branch
from

Conversation

BukunmiOla
Copy link

@BukunmiOla BukunmiOla commented Oct 14, 2024

What's in this PR?

This PR addresses issue #507 to increase test coverage by adding unit tests for the methods in ColorRule Class under DataClass
The test description and results are given below.

Added Tests

  • givenColorRule_whenJsonRepresentationRequested_thenReturnMapOfAttributesToValues The test sets the expected json map and asserts that the output of getJsonRepresentation() is the same as expected.
  • givenColorRule_whenStringRequested_thenReturnStringOfAttributesToValuesAssignmentSeparatedByComma: The test creates ColorRule, sets the expected string and asserts true for the toString() result.
  • givenValidColorRuleInTableRow_whenRowSearched_thenReturnTrue: This test cover checking if the entry of a row matches the ColorRule based on the ruleType.
  • givenValidColorRuleInTableRow_whenRowSearched_andOperatorIsNoOp_orDiffElementTypeSpec_thenReturnFalse This test covers cases where a false is expected from match result such as when the Element type is different or when the operator I not a valid operator.
  • givenValidStringValue_whenGetEnumIsCalled_thenReturnCorrectRuleType: Confirms that the RuleType returned from a String matches the correct ruleType.
  • givenInvalidStringValue_whenGetEnumIsCalled_thenReturnCorrectRuleType confirms an exception is thrown when an invalid string is supplied.
  • givenColorRuleType_whenGetSymbolIsCalled_thenReturnCorrectSymbol: Confirms that the symbol returned is correct.
  • `givenColorRule_whenJsonRepresentationRequested_thenReturnMapOfAttributesToValues' - This test confirms that the map of values

Result

image

This test has improved class coverage and method coverage to 100% and line coverage to 97% for the data class as shown below.

Before

image

After

image

What is left to be done in the addressed issue?

Logging Class
DateUtil Class

What problems did you encounter?

In creating the test cases, I ran into the Error: "Method ... not mocked" for the alpha and rgb color formats for Color in android.graphics.

@BukunmiOla BukunmiOla changed the title unit test for getJsonRepresentation function Test coverage for Data Classes Oct 14, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants