การใช้แอตทริบิวต์ TestIntialize คืออะไร เมื่อฉันทำทุกอย่างใน ClassIntialize ในการทดสอบ MS ได้ [ทำซ้ำ]

 [ClassInitialize]
    public static void ReportClassSetup(TestContext context)
    {
        BaseAdapter.ConnectionString = ConfigurationManager.ConnectionStrings["PremierConfig"].ConnectionString;
        IServiceContext serviceContext = new ServiceContextTest();
        var backgroundQueueService = new Camp.Core.Queue.DedicatedThreadTaskQueueService("PremierWebQueueService");
        backgroundQueueService.Start();
        var internalLoggerBackgroundService = new InternalLoggerBackgroundService()
        {
            QueueService = backgroundQueueService
        };
        _service = new InternalService(new DummyAuthorizationManager(), null, null)
        {
            ServiceContext = serviceContext,
            InternalLoggerBackgroundService = internalLoggerBackgroundService
        };
    }

    [TestInitialize]
    public void ReportTestSetup()
    {

    }

    [TestMethod]
    public void GetUserActivityReport1()
    {
       Assert.IsNotNull(_service.GetUserActivityReport(1));
    }

ในโค้ดข้างต้น การกำหนดค่าเริ่มต้นและการตั้งค่าทั้งหมด ฉันสามารถทำได้ในการจัดประเภท แล้ว TestInitalize มีประโยชน์อย่างไร


person Sparrow    schedule 18.01.2018    source แหล่งที่มา
comment
มีเพียงคำจำกัดความเท่านั้นที่กล่าวถึง ไม่มีเหตุผลใช่ไหม? หรือตัวอย่างเชิงปฏิบัติว่าทำไมต้องไปสอบ ?   -  person Sparrow    schedule 19.01.2018