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

feature/227 assertionmethod #229

Merged
merged 5 commits into from
Oct 8, 2020
Merged

feature/227 assertionmethod #229

merged 5 commits into from
Oct 8, 2020

Conversation

egil
Copy link
Member

@egil egil commented Oct 7, 2020

Marked MarkupMatches and WaitForAssertion as assertion methods.

Details in #227.

@egil egil changed the base branch from main to dev October 7, 2020 17:03
@egil egil linked an issue Oct 7, 2020 that may be closed by this pull request
@egil
Copy link
Member Author

egil commented Oct 7, 2020

Hi @pavel-mikula-sonarsource, can I get you to give this PR a very quick look and see if I am doing it right.

@codecov
Copy link

codecov bot commented Oct 7, 2020

Codecov Report

Merging #229 into dev will increase coverage by 0.13%.
The diff coverage is n/a.

Impacted file tree graph

@@            Coverage Diff             @@
##              dev     #229      +/-   ##
==========================================
+ Coverage   79.18%   79.31%   +0.13%     
==========================================
  Files         109      109              
  Lines        3046     3046              
  Branches      396      396              
==========================================
+ Hits         2412     2416       +4     
+ Misses        504      502       -2     
+ Partials      130      128       -2     
Impacted Files Coverage Δ
...Helpers/RenderedFragmentWaitForHelperExtensions.cs 100.00% <ø> (ø)
...nit.web/Asserting/MarkupMatchesAssertExtensions.cs 12.50% <ø> (ø)
...it.core/Extensions/WaitForHelpers/WaitForHelper.cs 92.50% <0.00%> (+5.00%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update d966bcb...6e06b85. Read the comment docs.

Copy link
Contributor

@pavel-mikula-sonarsource pavel-mikula-sonarsource left a comment

Choose a reason for hiding this comment

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

LGTM, I left some minor improvement suggestions

src/bunit.core/Asserting/AssertionMethodAttribute.cs Outdated Show resolved Hide resolved
@@ -42,6 +43,7 @@ public static void WaitForState(this IRenderedFragmentBase renderedFragment, Fun
/// <param name="assertion">The verification or assertion to perform.</param>
/// <param name="timeout">The maximum time to attempt the verification.</param>
/// <exception cref="WaitForFailedException">Thrown if the timeout has been reached. See the inner exception to see the captured assertion exception.</exception>
[AssertionMethod]
Copy link
Contributor

Choose a reason for hiding this comment

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

There's inconsistency in the codebase. This method doesn't need it for purpose of SonarSource analyzers, because it contains Assert.
And there exist other assertion methods (like DiffAssertExtensions) that don't need it and don't have it.

CHANGELOG.md Outdated
@@ -34,7 +34,8 @@ List of changes in existing functionality.
);
```
By [@egil](https://github.com/egil) in [#203](https://github.com/egil/bUnit/pull/203).
- All test doubles are now in the same namespace, `Bunit.TestDoubles`. So all import statements for `Bunit.TestDoubles.JSInterop` and `Bunit.TestDoubles.Authorization` must be changed to `Bunit.TestDoubles`. By [@egil](https://github.com/egil) in [#203](https://github.com/egil/bUnit/pull/223).
- All test doubles are now in the same namespace, `Bunit.TestDoubles`. So all import statements for `Bunit.TestDoubles.JSInterop` and `Bunit.TestDoubles.Authorization` must be changed to `Bunit.TestDoubles`. By [@egil](https://github.com/egil) in [#223](https://github.com/egil/bUnit/pull/223).
- Marked MarkupMatches and WaitForAssertion as assertion methods to stop SonarQube analyzers complaining about missing assertions in tests. By [@egil](https://github.com/egil) in [#229](https://github.com/egil/bUnit/pull/229).
Copy link
Contributor

Choose a reason for hiding this comment

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

To keep it simple and accurate: We have SonarQube, SonarCloud, SonarLint and also standalone NuGet packages that might complain about this.

Suggested change
- Marked MarkupMatches and WaitForAssertion as assertion methods to stop SonarQube analyzers complaining about missing assertions in tests. By [@egil](https://github.com/egil) in [#229](https://github.com/egil/bUnit/pull/229).
- Marked MarkupMatches and WaitForAssertion as assertion methods to stop SonarSource analyzers complaining about missing assertions in tests. By [@egil](https://github.com/egil) in [#229](https://github.com/egil/bUnit/pull/229).

@egil
Copy link
Member Author

egil commented Oct 8, 2020

Thanks @pavel-mikula-sonarsource. Appreciate the input.

Co-authored-by: Pavel Mikula <57188685+pavel-mikula-sonarsource@users.noreply.github.com>
CHANGELOG.md Outdated Show resolved Hide resolved
@egil egil merged commit c222cf7 into dev Oct 8, 2020
@sonarcloud
Copy link

sonarcloud bot commented Oct 8, 2020

Kudos, SonarCloud Quality Gate passed!

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities (and Security Hotspot 0 Security Hotspots to review)
Code Smell A 0 Code Smells

No Coverage information No Coverage information
0.0% 0.0% Duplication

@egil egil deleted the feature/227-assertionmethod branch October 8, 2020 09:35
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.

Mark custom assertion methods with SonarSource attribute
2 participants