Posts

Showing posts from August, 2019

UITestCase Automation Testing with Xcode

Image
UITestCase using Xcode TestCases for UI helps to automate the testing. In case of iOS , it is subclass of XCTestCase , which is part of XCTest framework . The subclassed object can be usually considered a Test Suite. A Test Suite is nothing but a group of similar test classes intended to test a specific behavior. To understand more about the automation testing using Xcode , we will consider a simple example which will test the alert message being shown appropriately or not for each button being tapped. The code is available on GitHub .                 XCTestCase and life cycle of a test suite XCTestCase subclass objects has all the required methods to setup and run a test case. More precisely methods for test suite life cycle. a) class method setUp -> use this to initialize the inputs required , before the first test case executes. override class func setUp(){ } b) method setUp  -> executed every time before a test case runs overri

Closures in Swift

Closures in Swift Closures in simple terms is a block of code which can be called any time during the current flow of execution. Closures have access to variables and function in the scope where they are defined. We can consider a simple array of numbers and try to transform it into a map with closure. let numbers = [1,2,3] The map function considers input a closure , will start with most extensive version of it as shown below. Iteration 1----------------------------------------------- let newMap = numbers . map ({ (input: Int ) -> Array < Int > in     return Array (repeating:input, count: input) }) "in" is used to separate the arguments and return type from the body. Iteration 2----------------------------------------------- If we see the Closure is the only parameter of the function . We can omit parentheses. We just removed () . let newMap2 = numbers . map { (input: Int ) -> Array < Int > in     re