質問をすることでしか得られない、回答やアドバイスがある。

15分調べてもわからないことは、質問しよう!

新規登録して質問してみよう
ただいま回答率
85.48%
TeamCity

TeamCityは、継続ユニットテストやコード品質分析及びビルド問題を早急に報告できるオールインワンソリューションツールです。インストールが容易で数分ですむところが特長です。

Q&A

0回答

1640閲覧

SpecFlow + WatiN + NUnit + TeamCity on Windows Server 2008 R2

onitail

総合スコア12

TeamCity

TeamCityは、継続ユニットテストやコード品質分析及びビルド問題を早急に報告できるオールインワンソリューションツールです。インストールが容易で数分ですむところが特長です。

0グッド

0クリップ

投稿2015/02/18 04:08

I just recently ran into some trouble setting up a fully automated nightly build / testing / deployment environment. To explain the setup in short. We use Mercurial as source control system and TeamCity as build server. It currently only has one build agent on a separate machine to keep things simple.

The idea is as follows: each night a TeamCity build runs. Pulls latest from Mercurial repository, runs a build, runs unit tests, deploys to test server, runs acceptance tests (on build agent) against freshly deployed test server and if all of that passes deploys the lot to a staging server. I've got everything working except for acceptance tests. These are done with SpecFlow and WatiN. Everyhting runs nicely on development machines (Windows 7 32 bit). However when I try to run the acceptance tests (NUnit in TeamCity) the runner reports fail beacuse of step [Browser].ContainsText(browserText). All steps up to that ran correctly and if I replicate the steps in the same browser on build agent (got full admin access) I can see the text being present. So to my best knowledge the test should pass.

I found this stackoverflow thread that got me thinking I may be doing somwthing wrong with how I keep the browser instance around. To explain: I have a set of common steps such as "when I click X button" or "when I enter text X into field Y" and the one with an issue "then then I am shown X". Because I'm making as much as possible of tests reusable I've also generalized a @requires_browser scenario requirement which is then defined like this:

[BeforeScenario("requires_browser")]
public void RequiresBrowserBeforeFeature()
{
Settings.MakeNewIeInstanceVisible = false;
ScenarioContext.Current.Set<Browser>(new IE(true));
}

[AfterScenario("requires_browser")]
public void RequiresBrowserAfterFeature()
{
ScenarioContext.Current.Get<Browser>().Close();
ScenarioContext.Current.Get<Browser>().Dispose();
}
and then the common step:

[Then("I am shown "(.*)"")]
public void ThenIAmShown(string text)
{
Assert.IsTrue(ScenarioContext.Current.Get<Browser>().ContainsText(text));
}
From this I can define other common steps that enter text into text boxes, click buttons and so on. All this works perfectly on development environment, running in visual studio 2010 [as administrator].

Am I wrong in thinking that ScenarioContext should be preserved until the test is finished?

What I've tried so far:

Configuring build agent service to run as local system (SYSTEM). This causes the issue as described - the ThenIAmShown(string text) method will always fail. It has interaction with local desktop enabled.

Configured build agent service to run as network administrator (full admin rights). This setup won't even runs tests. The exception I get:

TearDown method failed. WatiN.Core.Exceptions.BrowserNotFoundException : Could not find an IE window matching constraint: Timeout while waiting to attach to newly created instance of IE.. Search expired after '30' seconds. TearDown : System.Collections.Generic.KeyNotFoundException : The given key was not present in the dictionary. at WatiN.Core.IE.CreateIEPartiallyInitializedInNewProcess() at WatiN.Core.IE.CreateNewIEAndGoToUri(Uri uri, IDialogHandler logonDialogHandler, Boolean createInNewProcess) ...

Already added assemblies Interop.SHDocVw.dll and Microsoft.mshtml.dll to bin directory (Copy To Output in project references).

Running NUnit UI from the build agent. This runs the unit tests as expected. Leads me to believe there might be an issue with security. Runnint NUnit 2.0.5 on Windows Server 2008 R2 Enterprise.

Anyone had this issue?

気になる質問をクリップする

クリップした質問は、後からいつでもMYページで確認できます。

またクリップした質問に回答があった際、通知やメールを受け取ることができます。

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

guest

あなたの回答

tips

太字

斜体

打ち消し線

見出し

引用テキストの挿入

コードの挿入

リンクの挿入

リストの挿入

番号リストの挿入

表の挿入

水平線の挿入

プレビュー

まだ回答がついていません

会員登録して回答してみよう

アカウントをお持ちの方は

15分調べてもわからないことは
teratailで質問しよう!

ただいまの回答率
85.48%

質問をまとめることで
思考を整理して素早く解決

テンプレート機能で
簡単に質問をまとめる

質問する

関連した質問