Is it possible to unit test a static library project using XCode's SenTestingKit?

后端 未结 4 1600
不知归路
不知归路 2021-01-04 06:33

I\'ve created an iOS unit test target for doing logic tests following the steps provided in Apple\'s documentation.

However my build fails and i get the following e

4条回答
  •  抹茶落季
    2021-01-04 07:04

    Due to the nature of static libraries, you can't perform application tests, which by the sound of it is what you are trying to do. However, you can perform logic tests.

    You were correct in your observation about unit testing in the client application.

    The Xcode template optionally includes unit tests, but if you go to the build settings for that unit test you will see it doesn't specify a test host or bundle loader. This is because of the nature of static libraries. They are not applications, they are libraries - so you can do logic tests, you cannot do application tests.

    Application tests you may wish to perform on your static library may include the following scenario:

    My library creates an SQLite database at runtime, I wish to perform a unit test to check everything is inserting and/or updating as expected.

    In order to test this with unit tests, one must create another application which includes or otherwise is dependant of your library. This application then includes your library and application tests may then be set up there.

提交回复
热议问题