If they differ, the test will fail instead. In this case, XCTAssertEqual will compare the first two values given to it and make sure that they're equal. Inside of the test, assertion APIs are used to evaluate and validate your source code. You'll also see a test diamond appear to the left of the test to show that Xcode can execute it. Each method we want to use as a test case must start with the word test and then hopefully be named something that indicates what it will do. The class itself is a subclass of XCTest case which allows its methods to be used by Xcode to execute tests. The class imports the XCTest framework along with the target to be tested. Now let's take a closer look at a test class that uses XCTest. You are also provided with the template to start writing each of these test classes and the test cases within them. In our brand new project, you can see the unit tests targeting class and the UI tests targeting class automatically created and displayed in your project navigator. The easiest way to get started with testing in your Xcode project is to choose to include both unit and UI tests when starting a new project. Today, we'll be focusing on unit and UI tests. Lastly, performance tests run multiple times over a given test to look at the average timing, memory usage or other metric given to it to make sure you don't introduce regressions in these areas. UI tests will be able to make sure that everything behaves correctly at the very end. UI tests are also black box test because they won't rely on any knowledge of the functions or classes actually supporting your app. UI tests execute on top of your app's UI to provide end-to-end qualification of your app. This includes both your standard unit test and also your integration tests. Unit tests in XCTest are all of your tests targeting your source code. So we just went over how to balance your test suite, so now let's switch to the tools provided by XCTest to help you implement it. The full pyramid of tests can therefore help you balance between these three different test types and ensures your test suite gives you the coverage that you need. UI tests also require more maintenance because your app's UI may change more frequently. UI tests take the longest to run but they're vital to demonstrating that everything behaves correctly. This makes sure that your app truly does what you expect it to. Lastly, user interface or UI tests observe the user-phasing behavior of your app. They may take slightly longer to run but they do test more of your app at once. You generally also won't need as many integration tests as unit test. Integration tests sit on top of unit tests, because you want to make sure that the individual functions behave correctly before testing this larger piece of your code. These tests should target discrete subsystems or clusters of classes to make sure that different components behave correctly together. Integration tests are used to validate a larger section of your code. This is the foundation of all of our testing so you want to write many unit tests to cover all your functions. Unit tests are short, simple, and run very quickly. This is done by inputting variables to the function and checking that they return the expected output. Unit tests help verify a single piece of code, generally a function. Unit tests are the foundation of our pyramid. The pyramid model approach to testing helps to strike a balance between thoroughness, quality and execution speed. We're going to start with a summary of how you should consider planning out the automation test suite of any project. You can also use test to codify requirements, meaning you make test for expected behaviors for your app, and further work by you and your team can be qualified against these expectations. Testing is an important step of developing any project which can help you find bugs in your source code. XCTest is the automation testing framework provided in Xcode with built-in support to help you set up and execute your tests. Finally, Ethan will show you applications of XCTest with continuous integration. Then, Stuart will tell you about the test plans feature. In today's session, we'll start with an introduction to testing in XCode with XCTest. My name is Ana Calinov and I'll be presenting along with my colleagues, Stuart Montgomery and Ethan Vaughan. Good morning, and welcome to Testing in Xcode.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |