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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T06:15:28+00:00 2026-05-25T06:15:28+00:00

We have tests using WatiN that we want to run on our CruiseControl.NET server.

  • 0

We have tests using WatiN that we want to run on our CruiseControl.NET server. We have got it working with one single build. When we enable these tests in other builds they fail when they run at the same time. We would like to avoid putting all the builds running these tests on the same cc.net queue, because these tests are just a small portion of the whole build time. We would also like to avoid having seperate build projects for these tests because that would literally double the amount of builds in our cc.net setup.

What options do we have?

  1. Is there any way to put these test in its own cc.net task and put just that task on a queue?
  2. Is there any msbuild/nant/ccnet task or whatever that handles queuing?
  3. Is there any command line tool that we can run from our msbuild script that handles queuing of command line tasks, so that we can run our tests using a nunit command line calls?
  4. Is there any other smart solutions to this problem?

If we dont find any existing solution to this problem, we will probably build something ourselves, if so, which solution would be recommended?

EDIT:
This was my final implementation of the mutex:

public class SystemLevelLock : IDisposable
{
    private readonly string _id;
    private bool _isAquired;
    private Mutex _mutex;

    public SystemLevelLock(string id)
    {
        _id = id;
        Aquire();
    }

    public SystemLevelLock() : this(GetApplicationId()) { }

    private void Aquire()
    {
        try
        {
            var mutex = GetMutex();
            _isAquired = mutex.WaitOne(TimeSpan.FromMinutes(1), false);
            if (!_isAquired)
                throw new Exception("System level mutex could not be aquired");
        }
        catch (AbandonedMutexException)
        {
            // Mutex was abandoned by another process (it probably crashed)
            // Mutex was aquired by this process instead
        }
    }

    private Mutex GetMutex() { return _mutex ?? (_mutex = MakeMutex()); }

    private Mutex MakeMutex()
    {
        var mutexId = string.Format("Global\\{{{0}}}", _id);
        var allowEveryoneRule = new MutexAccessRule(new SecurityIdentifier(WellKnownSidType.WorldSid, null), MutexRights.FullControl, AccessControlType.Allow);
        var securitySettings = new MutexSecurity();
        securitySettings.AddAccessRule(allowEveryoneRule);
        var mutex = new Mutex(false, mutexId);
        mutex.SetAccessControl(securitySettings);
        return mutex;
    }

    private void Release()
    {
        if (_isAquired)
            _mutex.ReleaseMutex();
    }

    public void Dispose() { Release(); }

}

And this is the Browser class implementation that uses the mutex. This is also using the SpecFlow scenariocontext to store the browser instance and lock for this scenario.

public static class Browser
{

    public static IE Current
    {
        get
        {
            if (!IsStarted())
                Start();
            return ScenarioBrowser;
        }
    }

    private static IE ScenarioBrowser
    {
        get
        {
            if (ScenarioContext.Current.ContainsKey("browser"))
                return ScenarioContext.Current["browser"] as IE;
            return null;
        }
        set
        {
            if (value == null)
            {
                if (ScenarioContext.Current.ContainsKey("browser"))
                    ScenarioContext.Current.Remove("browser");
            }
            else
                ScenarioContext.Current["browser"] = value;
        }
    }

    private static IDisposable BrowserLock
    {
        get
        {
            if (ScenarioContext.Current.ContainsKey("browserLock"))
                return ScenarioContext.Current["browserLock"] as IDisposable;
            return null;
        }
        set
        {
            if (value == null)
            {
                if (ScenarioContext.Current.ContainsKey("browserLock"))
                    ScenarioContext.Current.Remove("browserLock");
            }
            else
                ScenarioContext.Current["browserLock"] = value;
        }
    }

    private static void LockBrowser()
    {
        BrowserLock = MakeBrowserLock();
    }

    private static void ReleaseBrowser()
    {
        BrowserLock.Dispose();
        BrowserLock = null;
    }

    private static SystemLevelLock MakeBrowserLock() { return new SystemLevelLock("WatiNBrowserLock"); }

    private static void Start()
    {
        LockBrowser();
        var browser = new IE();
        ScenarioBrowser = browser;
    }

    public static bool IsStarted() { return ScenarioBrowser != null; }

    public static void Close()
    {
        try
        {
            var browser = ScenarioBrowser;
            ScenarioBrowser = null;
            browser.Close();
            browser.Dispose();
        }
        finally
        {
            ReleaseBrowser();
        }
    }

}
  • 1 1 Answer
  • 1 View
  • 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-25T06:15:28+00:00Added an answer on May 25, 2026 at 6:15 am

    It seems like your tests are not isolated. You need ensure that the tests set up and run and in their own isolated environments. Do the tests depend on shared resources? Tests/Servers/Urls etc?

    Since your IE is a shared resource (are you sure it’s not the site). perhaps you could pause the the process with a custom task that waits on a system level named mutex.

    EDIT:
    This was my (MatteS) final implementation of the mutex:

    public class SystemLevelLock : IDisposable
    {
        private readonly string _id;
        private bool _isAquired;
        private Mutex _mutex;
    
        public SystemLevelLock(string id)
        {
            _id = id;
            Aquire();
        }
    
        public SystemLevelLock() : this(GetApplicationId()) { }
    
        private void Aquire()
        {
            try
            {
                var mutex = GetMutex();
                _isAquired = mutex.WaitOne(TimeSpan.FromMinutes(1), false);
                if (!_isAquired)
                    throw new Exception("System level mutex could not be aquired");
            }
            catch (AbandonedMutexException)
            {
                // Mutex was abandoned by another process (it probably crashed)
                // Mutex was aquired by this process instead
            }
        }
    
        private Mutex GetMutex() { return _mutex ?? (_mutex = MakeMutex()); }
    
        private Mutex MakeMutex()
        {
            var mutexId = string.Format("Global\\{{{0}}}", _id);
            var allowEveryoneRule = new MutexAccessRule(new SecurityIdentifier(WellKnownSidType.WorldSid, null), MutexRights.FullControl, AccessControlType.Allow);
            var securitySettings = new MutexSecurity();
            securitySettings.AddAccessRule(allowEveryoneRule);
            var mutex = new Mutex(false, mutexId);
            mutex.SetAccessControl(securitySettings);
            return mutex;
        }
    
        private void Release()
        {
            if (_isAquired)
                _mutex.ReleaseMutex();
        }
    
        public void Dispose() { Release(); }
    
    }
    

    And this is the Browser class implementation that uses the mutex. This is also using the SpecFlow scenariocontext to store the browser instance and lock for this scenario.

    public static class Browser
    {
    
        public static IE Current
        {
            get
            {
                if (!IsStarted())
                    Start();
                return ScenarioBrowser;
            }
        }
    
        private static IE ScenarioBrowser
        {
            get
            {
                if (ScenarioContext.Current.ContainsKey("browser"))
                    return ScenarioContext.Current["browser"] as IE;
                return null;
            }
            set
            {
                if (value == null)
                {
                    if (ScenarioContext.Current.ContainsKey("browser"))
                        ScenarioContext.Current.Remove("browser");
                }
                else
                    ScenarioContext.Current["browser"] = value;
            }
        }
    
        private static IDisposable BrowserLock
        {
            get
            {
                if (ScenarioContext.Current.ContainsKey("browserLock"))
                    return ScenarioContext.Current["browserLock"] as IDisposable;
                return null;
            }
            set
            {
                if (value == null)
                {
                    if (ScenarioContext.Current.ContainsKey("browserLock"))
                        ScenarioContext.Current.Remove("browserLock");
                }
                else
                    ScenarioContext.Current["browserLock"] = value;
            }
        }
    
        private static void LockBrowser()
        {
            BrowserLock = MakeBrowserLock();
        }
    
        private static void ReleaseBrowser()
        {
            BrowserLock.Dispose();
            BrowserLock = null;
        }
    
        private static SystemLevelLock MakeBrowserLock() { return new SystemLevelLock("WatiNBrowserLock"); }
    
        private static void Start()
        {
            LockBrowser();
            var browser = new IE();
            ScenarioBrowser = browser;
        }
    
        public static bool IsStarted() { return ScenarioBrowser != null; }
    
        public static void Close()
        {
            try
            {
                var browser = ScenarioBrowser;
                ScenarioBrowser = null;
                browser.Close();
                browser.Dispose();
            }
            finally
            {
                ReleaseBrowser();
            }
        }
    
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I just got started running UI tests against my ASP.NET MVC application using WatiN.
I have a set of cucumber tests that normally run fine against our site.
I have integration tests using RavenDB with RunInMemory = true . One of the
I have some tests created using Selenium WebDriver. When I run them using IE
I have recently started to learn Objective-C and write my tests using OCUnit that
We have some unit tests running against a SQL server 2000 database using the
I'm using Google Test Framework to set some unit tests. I have got three
I'm trying to run Watin from within a TeamCity build, using nUnit. All tests
In my current project we are testing our ASP.NET GUI using WatiN and Mbunit
I added some simple WatiN tests to our app today to check that a

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.