以下の内容はhttps://cheatography.com///gregfinzer/cheat-sheets/nunit/より取得しました。


Cheatography

NUnit Cheat Sheet by

NUnit example of setup, teardown, and testing

References

Code Example

using System;
using NUnit.Framework;

namespace NUnitPoc
{
    [TestFixture,Category("Optional Category Attribute"), Description("Optional Description")]
    public class NUnitPocTests
    {
        // Code run once before all tests
        [OneTimeSetUp]
        public void OneTimeInitialization()
        {
        }

        // Code that is run once after all tests
        [OneTimeTearDown]
        public void OneTimeCleanup()
        {
        }

        // Code that is run once before each test
        [SetUp]
        public void Initialize()
        {
        }

        // Code that is run once after each test
        [TearDown]
        public void Cleanup()
        {
        }

        //Example Test
        [Test]
        public void ExampleTest()
        {
            //Arrange.  
            int expected = 1;

            //Act
            int? actual = MethodToTest();

            //Assert
            Assert.IsTrue(expected == actual, "expected == actual");

            //Other example assets
            Assert.AreEqual(expected, actual);
            Assert.IsFalse(false);
            Assert.IsEmpty(string.Empty);
            //Assert.Fail("Explicitly Fail");
            Assert.Throws<NotImplementedException>(NotImplementedMethod);
        }

        [Test]
        public void ParameterizedTest([Values(1, 2, 3)] int value)
        {
            //Do some testing here
            Console.WriteLine(value);
        }

        private int MethodToTest()
        {
            return 1;
        }

        private void NotImplementedMethod()
        {
            throw new NotImplementedException();
        }
    }
}
 

Comments

No comments yet. Add yours below!

Add a Comment

Related Cheat Sheets

Selenium WebDriver Cheat Sheet Cheat Sheet
Cypressio Cheat Sheet
ISTQB Test Automation Engineering Cheat Sheet

More Cheat Sheets by GregFinzer

Loving Your Neighbor Cheat Sheet
AWS Fundamental Cloud Concepts Cheat Sheet
AWS Core Service Options Cheat Sheet



以上の内容はhttps://cheatography.com///gregfinzer/cheat-sheets/nunit/より取得しました。
このページはhttp://font.textar.tv/のウェブフォントを使用してます

不具合報告/要望等はこちらへお願いします。
モバイルやる夫Viewer Ver0.14