2014-06-12 11:23:41

1. Arrange

Do what is necessary to set up the test.

Here we will arrange the test. For example, We may create an object of the targeted class, then create mock objects and other variable initializations.

2. Act

Execute the test.

We act on the unit test and obtain the result.

3. Assert

Check and verify the returned result.

Assert a claim about the outcome.

Example

using System;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using MyProject;

namespace UnitTest
{
    [TestClass]   
    public class UnitTest
    {
        [TestMethod]
        public void TestMethod()
        {
            //Arrange test
            var obj = new myClass();
            var aValue = "test";
            Boolean result;

            //Act test
            result = obj.myMethod(aValue);

            //Assert test
            Assert.AreEqual(true, result);
        }
    }
}
Arrange, Act, Assert
Copyright © 2025 delaney. All rights reserved.