在软件测试过程中使用NUnit进行并发测试

发表于:2009-06-03来源:作者:点击数: 标签:软件测试nunitNUnitNunitNUNIT
下面的代码将演示如何使用 NUnit 进行并发 测试 ,启动多线程插入多个数据,并在插入完数据后删除数据 usingSystem; usingSystem.Collections.Generic; usingSystem.Text; usingNUnit.Framework; usingWYEng. SQL ServerDAL; usingSystem.Threading; usingSys
下面的代码将演示如何使用NUnit进行并发测试,启动多线程插入多个数据,并在插入完数据后删除数据

 

using System;
using System.Collections.Generic;
using System.Text;
using NUnit.Framework;
using WYEng.SQLServerDAL;
using System.Threading;
using System.Data;
using System.Data.SqlClient;

namespace WYEng.TestUnit
...{
    [TestFixture]
    public class ExamComputerInfo
    ...{
        SQLServerDAL.ExamComputerInfo computerInfo;
        WYEng.Model.ExamComputerInfo mCompuerInfo;
        private int j = 0;
        private int computerID = 0;
        private string PARAM_COMPUTERID = \"@ComputerID\";
        [SetUp]
        public void CreateObject()
        ...{
            computerInfo = new WYEng.SQLServerDAL.ExamComputerInfo();
            mCompuerInfo = new WYEng.Model.ExamComputerInfo();
            TestGetComputerID();
        }

        [TearDown]
        public void DeleteObject()
        ...{
            TestDeleteComputerInfo();
            computerInfo = null;
            mCompuerInfo = null;

        }
        private void TestGetComputerID()
        ...{
            computerID = XPWY.DBUtility.DBHelperSQL.GetMaxID(\"ComputerID\", \"ExamComputerInfo\");
        } [Page]
        private void TestDeleteComputerInfo()
        ...{
            Console.WriteLine(computerID.ToString());
            string strSql = \"DELETE FROM ExamComputerInfo WHERE ComputerID>=

@ComputerID\";
            SqlParameter pram = new SqlParameter(PARAM_COMPUTERID, SqlDbType.Int);
            pram.Value = computerID;
            XPWY.DBUtility.DBHelperSQL.ExecuteSql(strSql,pram);
        }
        [Test]

原文转自:http://www.ltesting.net