Getting started

In order to use Ivonna, you have to install the latest version of TypeMock Isolator.

Setting up the Web site.

  1. Create a Web site and add a file Default.aspx if it's not already present.
  2. Add a label to the page and change its ID to "HelloLabel".
  3. Add a textbox to the page and change its ID to "NameTextbox".
  4. Add a button to the page and change its ID to "HelloButton".

Setting up the test project

  1. Add a WebTest project to the solution, found in the Test project template folder.
  2. Switch off Shadow Copying (Deployment in MsTest) in your test runner
    (Note: if you want to use the Microsoft Test Framework, read this).
  3. Add a class to your project. Decorate it with the TestFixtureAttribute and the Ivonna.Framework.RunOnWebAttribute.
  4. Add a method to your class, and decorate it with the TestAttribute.
  5. Each test method should begin with obtaining a reference to a TestSession instance.
  6. Execute a GET request usingt this instance and obtain a reference to the page using the GetPage method.
  7. Find the textbox and set its text to "John".
  8. Execute a postback request using the session's ExecutePostback method and obtain a reference to the page.
  9. Find the HelloLabel label and assert that it's text is equal to "Hello John".

The full code should look like this:


Imports Ivonna.Framework
Imports MbUnit.Framework
Imports Ivonna.Framework.WebForms
<TestFixture(), RunOnWeb()> Public Class WebTester
''' <summary>
''' We verify that we can get a valid reference to the Page object.
''' </summary>

<Test()> Sub CanGetThePage()
	Dim session As New TestSession 'Start each test with this
	Dim page As Web.UI.Page = session.GetPage("Default.aspx")
End Sub
''' <summary>
''' We verify that if we enter "John" in the textbox 
''' and click the button, the text of the label becomes "Hello John".
''' </summary>
<Test()> Sub HelloLabel_Displays_HelloJohn()
	Dim session As New TestSession
	'Get the page before writing to the textbox.
	Dim testPage As Web.UI.Page = session.GetPage("Default.aspx")
	Dim textBox As Web.UI.WebControls.TextBox =
	textBox.Text = "John" 'Write something
	'When we click a button, a new Page object is created.
	testPage = session.ProcessPostback("HelloButton")
	Dim label As Web.UI.WebControls.Label =
	Assert.AreEqual("Hello John", label.Text)
End Sub
End Class

using System.Web.UI;
using System.Web.UI.WebControls;
using Ivonna.Framework;
using Ivonna.Framework.WebForms;
using MbUnit.Framework;
namespace SampleTests
public class WebTester {
/// <summary>
/// We verify that we can get a valid reference to the Page object.
/// </summary>
public void CanGetThePage() {
	TestSession session = new TestSession(); //Start each test with this
	System.Web.UI.Page page = session.GetPage("Default.aspx");
public void HelloLabel_Displays_HelloJohn() {
	TestSession session = new TestSession();
	//Get the page before writing to the textbox.	
	Page page = session.GetPage("Default.aspx");
	TextBox textBox = 
	textBox.Text = "John"//Write something
	//When we click a button, a new Page object is created. 
	page = session.ProcessPostback("HelloButton"); 
	Label label = 
	Assert.AreEqual("Hello John", label.Text);
Note: you can see the MVC samples at the Code Samples page.

Latest news

Latest blog posts

Powered by FeedBurner