zoukankan      html  css  js  c++  java
  • 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


     

  • 相关阅读:
    jQuery全选反选全不选
    Ubuntu安装VMware Workstation8.0.3
    ubuntu安装的软件如何启动
    ubuntu装VirtualBox遇到的问题
    你是优秀的PHP程序员吗?
    VMWare 三种工作模式(bridged、hostonly、NAT)
    最近要做的事
    090224
    2月23日 月曜日
    周五 26日
  • 原文地址:https://www.cnblogs.com/margiex/p/240922.html
Copyright © 2011-2022 走看看