Skip to content

Categories:

Setting up WatiN with NUnit on Windows 7

  1. Copy WatiN.Core.dll and Interop.SHDocVw.dll from the WatiN installation folder to your project’s bin folder
  2. Add “using WatiN.Core” directive to the top of your code
  3. The correct threadstate needs to be set (http://watin.sourceforge.net/apartmentstateinfo.html)
    1. Create a file in your bin directory which has the same name as your assembly or executable, but with “.config” at the end. Eg: FOr “myFile.exe” create “myFile.exe.config”
    2. Paste in the following:
      <?xml version="1.0" encoding="utf-8" ?>
      <configuration>
        <configSections>
          <sectionGroup name="NUnit">
            <section name="TestRunner" type="System.Configuration.NameValueSectionHandler"/>
          </sectionGroup>
        </configSections>
        <NUnit>
          <TestRunner>
            <!-- Valid values are STA,MTA. Others ignored. -->
            <add key="ApartmentState" value="STA" />
          </TestRunner>
        </NUnit>
      </configuration>
    3. That will let you run tests in NUnit if you load the assembly or executable directly into NUnit. If you want to create an NUnit project, you will also need to copy that config file into the directory that the NUnit project file is saved in.
  4. Add localhost, as well as any other external sites the application references to “Trusted Sites” in internet explorer. That means if you have google ads for example,. you will need to add googleads.g.doubleclick.net to the trusted sites list.
  5. You need to run NUnit as Administrator

Posted in Uncategorized.

Tagged with , , .


One Response

Stay in touch with the conversation, subscribe to the RSS feed for comments on this post.

  1. sam says

    I am recently shifted to windows 7. I am unable to run dialog handler in windows 7. It’s working on other platforms but couldnt fix it in 7. Tried upgrading watin and nunit but still getting same problem.