NUnit [TearDown] fails — what process is accessing my files?

前端 未结 11 2556
你的背包
你的背包 2021-02-12 14:17

Final Edit: I found a solution to the problem (at the bottom of the question).

I\'ve got an Nunit problem that\'s causing me grief. Edit:

11条回答
  •  独厮守ぢ
    2021-02-12 14:42

    Tear down is executed after each test.

    This attribute is used inside a TestFixture to provide a common set of functions that are performed after each test method is run.

    You should try to delete them all with TestFixtureTearDown:

        [TestFixtureTearDown]
        public void finish()
        {
            //Delete all file
        }
    

    Maybe one test is using the file that you try to delete in an other test. <-- [Stewart] As I stated in the question, it happens when I run only one test, so this isn't possible.

    Update You do not give enough information about what you are doing. Have you try to clean up all the Test file with only 1 test in your test file and try it? [Stewart] Yes. If it works [Stewart] (it doesn't) then it's that you have multiple test problem (they access each other). You need to cut down the problem to find the source. Then, come back here we will help you. for the moment it's only guessing that we can give you. [Stewart] I have already done these cut-downs of the problem that you suggest, you'll find that they're in my original question!

提交回复
热议问题