In this Article, we will see Unit Testing.
Create Simple Project with Single View Application. We don’t need any UI Portion for this unit testing.
Add following function in Fresh ViewController.swift File. we will generally test that function is working properly or not.
func getResult(_ value: Float) -> Float {
return (value + 10)
}
So, Unit testing basically testing our logic functionalities
Here we add core part of Unit Testing.
Click on ‘New Unit Test Target…’
Here every function will work as a separate testing functionality, Here you can run every function individual so you can test every diff functionality individual.
Here you can make your own functions, There will be one default function that you can use.
Here in the first line importing @testable import UnitTesting
Project name, cause I want to use its ViewControllers.
Then I made one Object from ViewController and assign its value to a functionsetup()
. now I can use any methods of that particular ViewController.
I’ve Created sample functiontestAddition()
, that will test our ViewController’s logic Functionality
we’ve got a result from the functiongetResult()
.
now XCTAssert()
this line will test that our expected answer is right or wrong
if your testing will run properly it will show
Else
Next is UI Testing.
Here you can download full Project source with Unit Testing & UI Testing.
In this episode of the The Lazy CEO Podcast,…
Join us for an enlightening episode of The CEO…
Creating multi-agent workflows is the future of AI development,…
How has sunflower lab's focus on integrating ai, data…
Businesses are quickly shifting towards optimized processes. And the…
Developers often make mistakes when using Power Automate, which…