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 7561867
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T13:16:12+00:00 2026-05-30T13:16:12+00:00

exactly what does NUnit do when it encounters a timeout? I used to think

  • 0

exactly what does NUnit do when it encounters a timeout? I used to think it would abort the test by throwing a TimeoutException, but this test proves otherwise:

[Test, Timeout(100), ExpectedException(typeof(TimeoutException))]
public static void RaisingExpectedTimeoutException()
{
    Thread.Sleep(500);
}

unfortunately the nunit console only reports a violation of the timeout, but not how the test was aborted by it. is there anyone out there who knows more about how this would work? and why the above test did not raise the TimeoutException that I expected? (even though it is a .NET exception type, I figured NUnit used that Exception for timeout violations).

PS: this test method also fails:

[Test, Timeout(100), ExpectedException(typeof(ThreadAbortException))]
public static void RaisingExpectedThreadAbortException()
{
    Thread.Sleep(500);
}

and this test method succeeds (“nobody expects the spanish inquisition!”):

[Test, ExpectedException(typeof(ThreadAbortException))]
public static void ThrowingExpectedThreadAbortException()
{
    Thread.CurrentThread.Abort();
}
  • 1 1 Answer
  • 0 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-30T13:16:13+00:00Added an answer on May 30, 2026 at 1:16 pm

    If a test method in NUnit specifies a timeout then it will be run on a separate thread from the rest of the tests. If the test exceeds it’s timeout the created thread will be rudely aborted via Thread.Abort.

    The part about the abort is not explicit in the documentation but is evident upon digging into the NUnit code base. See TestThread.RunTest for the details.

    EDIT*

    The reason the test fails when it times out, even though you catch the exception, is because the test is marked as failed before it aborts the thread. Hence whether or not it’s expected is meaningless because it’s already marked as failed.

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

Sidebar

Related Questions

Can anyone tell me what exactly does this Java code do? SecureRandom random =
I would like to understand how exactly does sql count work. Is it a
What exactly does this instruction do? movzbl 0x01(%eax,%ecx), %eax
What exactly does this mean? $number = ( 3 - 2 + 7 )
What exactly does this instruction do? I know that it tries to align data
How exactly does one implement two separate tableviews on one view like in this
What exactly does it mean if the result of a junit test is Failed
What exactly does this mean -- Maybe IRB bug!? What does that tell me
I was wondering what this snippet exactly does? (found here: http://code.google.com/p/google-app-engine-samples/source/browse/trunk/django_example/django_bootstrap.py ) # Make
Possible Duplicate: Reference - What does this symbol mean in PHP? What exactly does

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.