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: restructure and enhance validation unit tests #4356

Merged
merged 19 commits into from
Dec 19, 2022

Conversation

vursen
Copy link
Contributor

@vursen vursen commented Dec 14, 2022

Description

  • Moved binder unit tests under the validation namespace.
  • Added unit tests that ensure the component properly implements the HasValidation interface methods. That was previously covered by integration tests but only to some extent.

A continuation of #4350.

Part of vaadin/platform#3066

Covered components

  • ComboBox
  • MultiSelectComboBox
  • CheckboxGroup
  • RadioButtonGroup
  • DatePicker
  • TimePicker
  • DateTimePicker
  • Select

Type of change

  • Internal

Checklist

  • I have read the contribution guide: https://vaadin.com/docs/latest/contributing/overview
  • I have added a description following the guideline.
  • The issue is created in the corresponding repository and I have referenced it.
  • I have added tests to ensure my change is effective and works as intended.
  • New and existing tests are passing locally with my change.
  • I have performed self-review and corrected misspellings.

@vursen vursen force-pushed the enhance-validation-unit-tests branch 4 times, most recently from c88008b to 879879c Compare December 14, 2022 14:17
@vursen vursen marked this pull request as ready for review December 14, 2022 14:18

@Test
public void setErrorMessage_getErrorMessage() {
HasValidationTestHelper.setErrorMessage_getErrorMessage(testField);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Extracting the logic definitely makes sense, however this specific pattern results in a lot of noise in Sonar validation, because it does not detect the assertions:
https://sonarcloud.io/project/issues?resolved=false&types=CODE_SMELL&pullRequest=4356&id=vaadin_flow-components&open=AYUQ_8ljB57jh_TraguY

Could we use an abstract test class instead, like AbstractionBasicValidationTest was used in the text field module?

@vursen vursen force-pushed the enhance-validation-unit-tests branch from 80241d4 to c5d2af7 Compare December 19, 2022 09:27

import org.junit.BeforeClass;

public abstract class AbstractValidationTest
Copy link
Contributor Author

@vursen vursen Dec 19, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

note: I assumed that this class can be removed likewise since it is no longer used in the codebase.

@sonarcloud
Copy link

sonarcloud bot commented Dec 19, 2022

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 22 Code Smells

No Coverage information No Coverage information
0.0% 0.0% Duplication

@vursen vursen merged commit 8e4e38d into master Dec 19, 2022
@vursen vursen deleted the enhance-validation-unit-tests branch December 19, 2022 12:22
@vursen vursen mentioned this pull request Dec 19, 2022
1 task
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.

None yet

2 participants