Skip to content

More code coverage#1871

Merged
jnyrup merged 8 commits intofluentassertions:developfrom
ITaluone:codecov
Apr 5, 2022
Merged

More code coverage#1871
jnyrup merged 8 commits intofluentassertions:developfrom
ITaluone:codecov

Conversation

@ITaluone
Copy link
Copy Markdown
Contributor

This ref. #1823

I don't know if these tests are important, but in case they are..

IMPORTANT

  • The code complies with the Coding Guidelines for C#.
  • The changes are covered by unit tests which follow the Arrange-Act-Assert syntax and the naming conventions such as is used in these tests.
  • If the PR adds a feature or fixes a bug, please update the release notes with a functional description that explains what the change means to consumers of this library, which are published on the website.
  • If the PR changes the public API the changes needs to be included by running AcceptApiChanges.ps1 or AcceptApiChanges.sh.
  • If the PR affects the documentation, please include your changes in this pull request so the documentation will appear on the website.

@ITaluone ITaluone changed the title Add test for guard helper class More code coverage Mar 31, 2022
Copy link
Copy Markdown
Member

@jnyrup jnyrup left a comment

Choose a reason for hiding this comment

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

Besides the single comment I'm good with this.

@ITaluone ITaluone requested a review from jnyrup April 1, 2022 05:01
@ITaluone
Copy link
Copy Markdown
Contributor Author

ITaluone commented Apr 1, 2022

I don't know how to arrange a test for ThrowIfArgumentIsOutOfRange.. Because T is an enum

@eNeRGy164
Copy link
Copy Markdown
Contributor

I don't know how to arrange a test for ThrowIfArgumentIsOutOfRange.. Because T is an enum

Cast any enum to a value that's not listed. For example (CSharpAccessModifier)1000

@ITaluone
Copy link
Copy Markdown
Contributor Author

ITaluone commented Apr 1, 2022

ahh.. thank you :)

@dennisdoomen
Copy link
Copy Markdown
Member

To be honest, I see no value in those extra tests. This is internal code that is already covered by all other code and only exists because of that other code. In fact, ThrowIfArgumentContainsNull can even be removed since it is dead code anyway.

@IT-VBFK
Copy link
Copy Markdown
Contributor

IT-VBFK commented Apr 1, 2022

Ok, removing dead code counts as "improve code coverage" IMO :)

@IT-VBFK
Copy link
Copy Markdown
Contributor

IT-VBFK commented Apr 1, 2022

But: I search for of this method.. I found four references (MethodInfoSelector, TypeSelectorAssertions, TypeSelector and PropertyInfoSelector)

I will check this tomorrow if this will have a negative side effect if I remove them..

@dennisdoomen
Copy link
Copy Markdown
Member

There's an overload.

@IT-VBFK
Copy link
Copy Markdown
Contributor

IT-VBFK commented Apr 1, 2022

How I can see the code coverage on coveralls for the latest CI build?

@jnyrup
Copy link
Copy Markdown
Member

jnyrup commented Apr 1, 2022

I've just started the CI pipeline.
Once it's done in ~10min the Coveralls bot will post a comment in this PR with a summary of the results.
To view the individual files you'll have to login to Coveralls with your GitHub account.

For the second latest commit, https://coveralls.io/builds/47906682/source?filename=Src%2FFluentAssertions%2FCommon%2FGuard.cs

@jnyrup
Copy link
Copy Markdown
Member

jnyrup commented Apr 1, 2022

@jnyrup
Copy link
Copy Markdown
Member

jnyrup commented Apr 1, 2022

Instead of adding tests of ThrowIfArgumentContainsNull<T>(IEnumerable<T> values, string paramName, string message) we could delete it, as it is dead code.

According to https://coveralls.io/builds/47932179/source?filename=Src%2FFluentAssertions%2FCommon%2FGuard.cs#L58
all the other lines are already covered by other tests.

@dennisdoomen
Copy link
Copy Markdown
Member

Instead of adding tests of ThrowIfArgumentContainsNull<T>(IEnumerable<T> values, string paramName, string message) we could delete it, as it is dead code.

That's exactly what I said ;-)

However, I don't get why Coverall did not post an update here. @eNeRGy164 any idea why it sometimes works and sometimes doesn't?

@IT-VBFK
Copy link
Copy Markdown
Contributor

IT-VBFK commented Apr 2, 2022

There's an overload.

Here is an example of what I have thought about to be able to remove ThrowIfArgumentContainsNull<T>().

This applies to all four assertions..

public MethodInfoSelector(IEnumerable<Type> types)
{
    types.ToList()
        .ForEach(type => Guard.ThrowIfArgumentIsNull(type, nameof(type)));
    Guard.ThrowIfArgumentIsNull(types, nameof(types));

    selectedMethods = types.SelectMany(t => t
        .GetMethods(BindingFlags.DeclaredOnly | BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic)
        .Where(method => !HasSpecialName(method)));
}

because removing the overload would be a breaking change IMO

@jnyrup
Copy link
Copy Markdown
Member

jnyrup commented Apr 2, 2022

It's non-breaking to remove any unused members of Guard since the class is internal.

So public static void ThrowIfArgumentContainsNull<T>(IEnumerable<T> values, string paramName) should be kept as it is used.

public static void ThrowIfArgumentContainsNull<T>(IEnumerable<T> values, string paramName, string message) can be removed as it unused and not public because Guard is internal.

@dennisdoomen
Copy link
Copy Markdown
Member

Maybe you're using an IDE that doesn't allow you to find usages, but my IDE (Rider) clearly tells me that the overload of ThrowIfArgumentContainsNull that takes three parameters isn't used at all.

image

@ITaluone
Copy link
Copy Markdown
Contributor Author

ITaluone commented Apr 4, 2022

ok, that was completely my fault 🙈

I have written the tests and therefore it showes up "2 usages".. (the tests)

I should have checked that before writing the tests :D

@eNeRGy164
Copy link
Copy Markdown
Contributor

eNeRGy164 commented Apr 4, 2022

However, I don't get why Coverall did not post an update here. @eNeRGy164 any idea why it sometimes works and sometimes doesn't?

At first, there was no run CI initiated by default because it's @ITaluone's first contribution.
But why there was no post after the actual run, I also don't know. I can only guess that maybe the API between Coveralls and GitHub is overloaded or something like that. Can't see anything specific.
I have seen posts appear when refreshing coveralls sync with GH in the past.

@dennisdoomen
Copy link
Copy Markdown
Member

I should have checked that before writing the tests :D

Those tests can be removed anyway.

@ITaluone
Copy link
Copy Markdown
Contributor Author

ITaluone commented Apr 5, 2022

ok, got it

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.

5 participants