1

I am using .net unit testing in my project. I would like to know if unit testing is required for UI part of the project or is it required for testing only class libraries.

If UI unit testing is needed how can i test a functionality like enter some text in a textbox and write those content to the webpage on the click of a button.

Thanks in advance.

6 Answers 6

2

VS 2010 Premium and Ultimate ship with Coded UI tests which do UI testing

Sign up to request clarification or add additional context in comments.

Comments

0

I think the usual plan is to put as little code in the UI as possible, putting everything into classes and unit testing them.

Possibly creating a class that shadows the UI and actually provides the actions that occur on button clicks etc will help you unit test as much functionality as possible.

1 Comment

If you are using any framework in ASP.NET this approach won't work since Web forms controls uses JavaScript and you won't be able to test any form of AJAX or bespoke JavaScript.
0

It's User Interface. You as a user can unit test every bit after running your project.

Firebug and Tamper Data are great tools that help you do that.

3 Comments

These are more debugging tools rather than unit testing tools.
@StuperUser: Any tool that lets you change data to try to break a unit is also a testing tool. Testing and debugging are not mutually exclusive.
Absolutely, and they're very useful in manual unit tests. Tamper Data looks a lot more powerful for that than Firebug.
0

I would look at a web automation tool such as Watin or selenium to automate the browser.

With Watin you can use .net to programatically find the elements on the page, Selenium you can record and replay.

Watin example

[Test] 
public void SearchForWatiNOnGoogle()
{
  using (var browser = new IE("http://www.google.com"))
  {
    browser.TextField(Find.ByName("q")).TypeText("WatiN");
    browser.Button(Find.ByName("btnG")).Click();

    Assert.IsTrue(browser.ContainsText("WatiN"));
  }
}

Comments

0

I have had success with unit testing my Javascript with QUnit and picking up the results of those tests with a single MSTest Unit test that uses WatiN.

Comments

0

With Visual Studio 2010 you can create coded UI Tests and you can also configure a Build agent to execute these tests: http://codesmartnothard.com/ConfiguringATFS2010TeamBuildServerToRunCodedUITests.aspx

this is exactly what you were asking, means you have a user interface and you can specify what should happen and in which controls, if user enters some data and clicks some buttons...

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.