Results 1 to 4 of 4

Thread: Stopping Tests in Code

  1. #1

    Thread Starter
    Hyperactive Member GlenW's Avatar
    Join Date
    Nov 2001
    Location
    Gateshead, England
    Posts
    479

    Stopping Tests in Code

    How do I stop a list of tests from executing, in code, if the first one fails?

    I have a large list of unit tests that need to be run against a project, these tests should not be run in full unless the database has been rebuilt. So, I want to check the database is empty and, if it isn't, abandon all further tests in the list.

    Obviously, checking the database is easy, but I cannot find any way of stopping the rest of the test list from executing in code.

    Any ideas?

  2. #2
    PowerPoster gep13's Avatar
    Join Date
    Nov 2004
    Location
    The Granite City
    Posts
    21,963

    Re: Stopping Tests in Code

    Hey,

    Rather than do that, use an Initialize method either at the start of all the unit tests, or have it run on a per test basis:

    http://msdn.microsoft.com/en-us/libr...attribute.aspx

    or

    http://msdn.microsoft.com/en-us/libr...attribute.aspx

    Hope that helps!!

    Gary

  3. #3

    Thread Starter
    Hyperactive Member GlenW's Avatar
    Join Date
    Nov 2001
    Location
    Gateshead, England
    Posts
    479

    Re: Stopping Tests in Code

    Quote Originally Posted by gep13 View Post
    Hope that helps!!
    Yes it does, thanks.
    In fact, it has given me an idea. I can check that the tables that have to be empty are, and if they are not, I can empty them there and then.

    Then re-run the delete stuff again in the Cleanup method, just to make sure.

    Or, I could just trust the testers to follow instructions ... maybe not.

  4. #4
    PowerPoster gep13's Avatar
    Join Date
    Nov 2004
    Location
    The Granite City
    Posts
    21,963

    Re: Stopping Tests in Code

    Quote Originally Posted by GlenW View Post
    Or, I could just trust the testers to follow instructions ... maybe not.
    Now that would just be silly

    Sounds like you have got the idea though. I would tend to have one method that blanks the entire database back to a known state, and then call that regardless before each test.

    Gary

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width