Config TeamCity to run UI Test on NUnit Framework

For Agent machine

  1. Install Firefox
  2. Install NUnit Adapter on Visual Studio
  3. Add Firefox path to PATH

For coding


For Teamcity

1. Specific agent machine for compatibility2

2. In Artifact paths of General Settings: Copy everything from Release folder to another folder (optional)3

3. Define steps

3.1 Restore packages4

3.2 Build and Package Test solution5.PNG

/p:Configuration=Release /p:Platform=”Any CPU” /p:FrameworkPathOverride=”C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.6.1″ /p:DeployOnBuild=true;PublishProfile=PackageToZip

3.3 Update Test parameters6.PNG

echo Username::%Test.Username% >\Test\UnitTest.CodeBase\bin\Release\Parameters.txt
echo Password::%Test.Password% >>\Test\UnitTest.CodeBase\bin\Release\Parameters.txt
echo SiteUrl::%Test.SiteUrl% >>\Test\UnitTest.CodeBase\bin\Release\Parameters.txt

3.4 Run UI Test in command line

Old\OmniaTest\UnitTest.CodeBase\bin\Release\TestWindow\vsTest.console.exe “\OmniaTest\UnitTest.CodeBase\bin\Release\UnitTest.CodeBase.dll” /UseVsixExtensions:true


Turn on read/write  permission for current user on: E:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\Common7\IDE\CommonExtensions\Microsoft\TestWindow

vsTest.console.exe %~dp0/UnitTest.CodeBase.dll /TestAdapterPath:”your packages path\Test\Dev\packages”


4. Define Parameters7

5. Turn on console mode in the build agent

cs stop TCBuildAgent
ping -n 1 -w 10000 > nul

C:\BuildAgent\bin\agent.bat start


Use selenium IDE to write UI Test for console log in C#

As always, your UI Test is just focus on what happen on the UI, such as find the element and act on that element. Sometime, all of the steps passed, and you think that this testcase pass? For me, I am not really sure for that.

Nowadays, most of web applications are using Javascript (or some libraries base on Javascript) for everything. So, how can we know that our web application don’t have any console error? Is it possible to write the UI Test to test console log?

The answer is “yes”. Here I will show you step by step to setup a UI Test method in Firefox.

1. Install Selenium IDE and Selenium IDE Button extension on Firefox, when you done that, your browser will look like this:


Now, you can record your steps for your testcase. The recorded steps will looks like this:


Now, what we need is export that testcase as C# code:


Now, it is the time for us to hijack the UI to actually override its console error.

The idea is: before the page actually loaded, we try to inject our javascript on the page, so I wrote an extension for driver to make it happen.


In here, we have a loop, trying to add your script to the page until it loaded. Since my page is so slow, my loop is base on second, but you can do the loop base on millisecond without any problem.

Now, in the login method, you just need to call to that method directly after you clicked on sign in button


Now, execute your steps and at the end, just read the errors for the final assert.


Ok, but what is “ReadErrors”? Ah, it is also an extension method to help us get all of console errors.


Yeah, everything seem finished. Now, you just need to run the test to see how it works.

To run the test, open command prompt and type:


Woa, for my testcase, I see this result:


He he, now you can see the Javascript error on your test. The test failed, but you successed :).


Add O365 account as a member of Visual Studio Online project

For testing purpose, follow this article to create a free 30-day trial of Office 365 Developer account.

When everything are ready, you should have an account and all the related apps like this:


In my case, my account is:

And, if you want to add this account to your Visual Studio Online project. Go to “Members” and add new user:


In the popup, type the account there, but unlucky, you see something like “No identities found”:


Don’t worries, just go ahead and click on “Save changes”.

Then, use another browser (or another user on same browser) and access to your project link, my case:

The login form will display for you to enter your account, but ops! What the hell is this?


Most of us will give-up at this time, but why? Why don’t you just go ahead and create a Microsoft account similar with O365 account and use it for both?


Then, go with some other steps and you are ready to use that account for your Visual Studio Online project.

Annoying, because they are still 2 difference users. So you still need to select a correct type when you want to access to any of them.