• nunit notes from TDD in .net


    Test case
    Test case is a self-validating programmer test that can be automatically discovered and executed independently of other test cases by a test runner.

    Test Suite
    A test suite is a collection of test cases or other test suites. The relationship between test cases and test suites is described by the Composite[2] pattern.

    Test Fixture
    A test fixture is a group of test cases sharing a common set of run-time resources.

    Tests and Test Fixtures
    One of the features of the NUnit Framework is its use of custom attributes. Attributes in .NET are the standard mechanisms to extend metadata about run- time entities. In this case, the run-time entities of interest are as follows:

    Test classes are the classes that contain test code; each test assembly has to have at lease one test class.
    Test methods are test cases; each test method represents a single test case that can be run independently of other test cases.

    Using SetUp/TearDown Attributes
    In the definition of a test fixture that we gave earlier, we said that tests in a test fixture share a common set of run-time resources. These common run-time resources may need to be acquired and initialized in a certain way before a test is executed and released or cleaned up after the test is completed. NUnit supports this common initialization/cleanup process using two additional custom attributes: SetUp and TearDown.

    Using ExpectedException
    You can use this attribute to indicate that an exception of a particular type is expected during the execution of the test method. If the method completes without throwing the expected exception, the test fails. Using this attribute helps in writing programmer tests that verify boundary conditions.

    Using the Ignore Attribute
    the Ignore attribute, you can keep the tests but not execute them.
    The Ignore attribute can be attached to either an individual test method or an entire test class (TestFixture).

    Using TestFixtureSetUp/TestFixtureTearDown
    NUnit has a pair of attributes that are similar to the SetUp/TearDown attributes discussed earlier: TestFixtureSetUp/TestFixtureTearDown. As their names suggest, these attributes are used to mark methods that initialize/release resources once for the entire test fixture.

    Test Life-Cycle Contract
    FixtureSetUp
    SetUp
    Test 1
    TearDown
    SetUp
    Test 2
    TearDown
    FixtureTearDown


     

  • 相关阅读:
    2018.11.5 Nescafe26 T1 小猫爬山
    2018.10.30 NOIp模拟赛T2 数字对
    2018.10.30 NOIp模拟赛 T1 改造二叉树
    2018/7/16 YMOI模拟 NOIP2013D2T3华容道
    数据结构实验
    我的第一个博客
    题解 P5035 【金坷垃】
    题解 P5036 【随机生成树】
    题解 P5037 【抓捕】
    题解 P1328 【生活大爆炸版石头剪刀布】
  • 原文地址:https://www.cnblogs.com/margiex/p/240922.html
Copyright © 2020-2023  润新知