Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 939295
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T21:46:02+00:00 2026-05-15T21:46:02+00:00

I have a couple of unit test helper extension methods, such as, IsNotEmpty(this string

  • 0

I have a couple of unit test helper extension methods, such as, IsNotEmpty(this string str) for which I have also written unit tests. The basic structure of these tests is that I have one test that verifies that the extension method passes and returns the expected result on a “good” input, and one that verifies that a fail exception is thrown on “bad” input. For example, the fail tests for the above method might look like this:

[TestMethod, Fails]
public void IsNotEmpty_Fails_On_Empty_String()
{
    "".IsNotEmpty();
}

where Fails is an attribute I wrote myself – basically a proxy for [ExpectedException(typeof(AssertFailedException))]. So I’m explicitly expecting an exception to be thrown on the only line in the above test, and thus, I’m not expecting the method to run all the way.

But when I right-click my solution, select “Test with->NCover”, I get less than 100% code coverage* on all methods like the above one, with the ending brace highlighted red.

Why does NCover complain about my test method not finishing, when I’ve said that it won’t?

**) For all those of you who will reply that 100% code coverage is not necessary: No, I’m not particularily worried about maintaining a 100% code coverage at all costs. However, in these cases methods that* do matter show up as not covered in the list, and I have to go all the way into the tree to see that it’s just them. That’s the issue I’m trying to get at here – not 100% code coverage in general.

  • 1 1 Answer
  • 2 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-15T21:46:02+00:00Added an answer on May 15, 2026 at 9:46 pm

    Are you running a debug build? That’s probably the issue. NCover works off of the debugging breakpoints, and Microsoft adds one to the closing bracket of each method so it can step there before leaving the method. Running in release mode should take care of those closing brackets for you.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

To ensure coding standards I have a couple of unit test which uses reflection
I have a couple of MFC applications. I don't want to unit-test UI but
I have couple of questions about AS3 variables handling by AVM/compiler/scope .1. This code
Here's the problem: I have couple of pages which gets its content from a
I usually unit test per class and this is no problem. However after messing
I have a unit test that works fine locally but when uploaded to TeamCity
I'm working on a project which I'm really not sure how to unit test.
I have troubles setting up unit test framework for windows phone sdk 7.1 there
We are currently using unit tests to test our project. We have the majority
I have couple of hyperlinks on my website. What I want is to remove

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.