using Microsoft.VisualStudio.TestTools.UnitTesting;
using SampleClassLib;
using System;
using System.Windows.Forms;
namespace TestNamespace
{
[TestClass()]
public sealed class DivideClassTest
{
[AssemblyInitialize()] //Before All Tests Across All Test Classes are run, mimics BeforeSuite in TestNG
public static void AssemblyInit(TestContext context)
{
MessageBox.Show("AssemblyInit " + context.TestName);
}
[ClassInitialize()]//Before All Tests in Test Class is run, mimics BeforeClass in TestNG
public static void ClassInit(TestContext context)
{
MessageBox.Show("ClassInit " + context.TestName);
}
[TestInitialize()] //Before Each Test Is Run, mimics BeforeTest in TestNG
public void Initialize()
{
MessageBox.Show("TestMethodInit");
}
[TestCleanup()] //After Each Test Is Run, mimics AfterTest in TestNG
public void Cleanup()
{
MessageBox.Show("TestMethodCleanup");
}
[ClassCleanup()] //After All Tests In Test Class are executed, mimics AfterClass in TestNG
public static void ClassCleanup()
{
MessageBox.Show("ClassCleanup");
}
[AssemblyCleanup()] //After All Tests Across All Test Classes are executed, mimics AterSuite in TestNG
public static void AssemblyCleanup()
{
MessageBox.Show("AssemblyCleanup");
}
[TestMethod()] //Test Method To Be Executed, mimics Test in TestNG
[ExpectedException(typeof(System.DivideByZeroException))]
public void DivideMethodTest()
{
DivideClass.DivideMethod(0);
}
}
}
Friday, 16 September 2016
MSTest Attributes Comparison With TestNG Test Attributes
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment