簡體   English   中英

xunit測試是否完全隔離運行?

[英]Do xunit tests run in total isolation?

如果我有一個靜態課程:

public static class Foo
{
    public static string Bar = "baz";
}

在xunit測試中,我做這樣的事情(做作):

public class FooTests
{
    [Fact]
    public void Bar_can_be_set_to_buz()
    {
        Foo.Bar = "buz";
    }

    [Fact]
    public void Some_other_test()
    {
        //Is Foo.Bar "buz", or is there isolation ?
    }
}

外部靜態類是兩個測試共享的,還是兩個測試之間完全隔離?

每個測試都會獲得測試類的新實例。 任何靜態都將在所有測試之間共享。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM