White in MS Test

May 10, 2010 at 6:26 PM

Hi all,

I've been building a large regression test using White and NUnit over the past several months, but would like to migrate to MS Test to take advantage of the new features in VS 2010 and avoid needing to open NUnit while building on an external server.

 

Has anyone attempted this? I would love for my "using WhiteCore = Core" to just work with the change, but like everything in life, it's not that simple.

Any suggestions are appreciated.

May 10, 2010 at 8:22 PM

Hi 32ndnote,

I've been using white with MSTest for acceptance testing on rather large modular WPF application. Can you give me some more details about the problems you've encountered?

May 10, 2010 at 8:40 PM

Thanks for the reply. I'm mostly just unsure as to which using directives I'm missing to make the change. Right now they look like this:

using System;
using System.IO;
using System.Reflection;
using System.Threading;
using Core.InputDevices;
using Core.UIItems;
using Core.UIItems.Finders;
using Core.UIItems.ListBoxItems;
using Core.UIItems.WindowItems;
using Core.WindowsAPI;
using WhiteCore = Core;
using Microsoft.VisualStudio.TestTools.UnitTesting;
The problem is at that 2nd to last line. 
An example of a TestMethod I have is:
[TestMethod]
        public void NewProjectWithOk()
        {
            if (Directory.Exists(ExePath + "\\" + ProjectLocation + "\\NewProject"))
            {
                Directory.Delete(ExePath + "\\" + ProjectLocation + "\\NewProject", true);
            }

            //Open New Project Button
            Button btn = _window.Get<Button>(NewProjectButton);
            btn.Click();

            Window childWindow = _window.ModalWindow("New Project");
            Assert.IsNotNull(childWindow);
            Assert.IsTrue(childWindow.IsModal);

            //Choose "Create New Data" and enter file path and name
            SearchCriteria searchCriteria = SearchCriteria.ByAutomationId("createNewData");
            RadioButton newDataButton = childWindow.Get<RadioButton>(searchCriteria);
            newDataButton.Click();

            searchCriteria = SearchCriteria.ByAutomationId("tbProjectName");
            TextBox projectNameBox = childWindow.Get<TextBox>(searchCriteria);
            projectNameBox.Text = "NewProject.yetiproj";

            searchCriteria = SearchCriteria.ByAutomationId("_PathTextBox");
            TextBox projectLocationBox = childWindow.Get<TextBox>(searchCriteria);
            string projectLocation = Path.Combine(ExePath, ProjectLocation);
            projectLocationBox.Text = projectLocation;

            //Open Project
            Button okButton = childWindow.Get<Button>("btnOk");
            okButton.Click();
        }
with errors at declarations at "Button", "Window", "SearchCriteria", "RadioButton", etc. 
May 10, 2010 at 9:15 PM

Ok, so….

I guess you’ve added reference to white.dll from your test project. In that case make sure you have using White.Core.UIItems in file header

Ivan Pavlović | paki@hive-studios.com | Hive Studios d.o.o. | www.hive-studios.com
Software Craftsman | MVP For C# MCAD MCSD MCDBA MCT Certified Scrum Master
Mike Alasa 54, 11000 Belgrade, Serbia | tel: +381 11 2928 716 | fax: + 381 11 2928 716
MSN ID: ipavlovi@hotmail.com MVP Pofile

May 10, 2010 at 9:17 PM

Excellent! Everything is working smoothly. Thanks for the help. I'm not sure where my head has been this morning.