Pregunta

¿Cómo se establece el estado de apartamento en el corredor NUnit interfaz gráfica de usuario? Estoy tratando de ejecutar una sola prueba NUnit con WatiN y yo estoy recibiendo el mensaje:

  

MyNamespace.LoginTests.CanLogin:
  System.Threading.ThreadStateException: El CurrentThread necesita tener es ApartmentState establece en ApartmentState.STA ser capaz de automatizar Internet Explorer

.
¿Fue útil?

Solución

Es necesario añadir un poco de configuración en un archivo app.config de su montaje (si usted no tiene una vez, crear una nueva) para contar NUnit para funcionar como STA:

<?xml version="1.0" encoding="utf-8" ?>

<configuration>
    <configSections>
        <sectionGroup name="NUnit">
            <section name="TestRunner" 
                     type="System.Configuration.NameValueSectionHandler"/>
        </sectionGroup>
    </configSections>

    <NUnit>
        <TestRunner>
            <add key="ApartmentState" value="STA" />
        </TestRunner>
    </NUnit>
</configuration>

( originales fuente)

Otros consejos

A partir de NUnit 2.5, utilice RequiresSTA atributo en sus pruebas.

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top