How to delete an Xcode Swift Test Class from the Test navigator?

前端 未结 3 950
名媛妹妹
名媛妹妹 2021-02-19 06:42

The Xcode Test navigator shows a list of test case classes.

I want to delete a test case class because it\'s no longer needed.

I\'ve tried many typical approach

相关标签:
3条回答
  • 2021-02-19 07:08

    Using Xcode 6.2, all I had to do was to switch to the Project navigator, select the file, and press delete. I then clicked the "Remove Reference" button in the confirmation dialog that appears. After that, the tests in that file disappeared from the Test navigator immediately. Adding the file back, the tests reappeared.

    I didn't have any need to delete the derived data folder, restart Xcode, etc.

    Adding the file to the project again instantly restored the tests in the Test navigator.

    This is certainly the desired behavior, and it sounds like it's broken in Xcode 6.3 but possibly fixed again in 6.3.1. So the real answer may just be that you need to upgrade to 6.3.1 (or downgrade to 6.2).

    Before:

    before files before tests

    After:

    after files after tests

    0 讨论(0)
  • 2021-02-19 07:09

    You can add and remove tests to the project easily using the class target membership checkbox. Find the class file in the Project Navigator and select it, then in the Utilities pane, click on the File Inspector and you will see a checkbox for target membership. You can toggle it on and off in there. target membership

    0 讨论(0)
  • If you want to delete just a single test class, you can click on the file name in the Project Navigator and press Delete and Move to Trash.

    If you want to delete then entire Testing bundle, click your project name in the Project Navigator. Then select your Tests target. Click the minus (-) button at the bottom to delete it.

    It is a good idea to do Unit Testing (and UI testing) in your projects. So if you want to add them back in then just click the plus (+) button.

    See also

    • How to do a Unit Test in Xcode
    • Xcode UI Test example
    0 讨论(0)
提交回复
热议问题