Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Example of Unit Testing in Swift #2

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

ApplebaumIan
Copy link
Contributor

  1. First Thing you gotta do is import the Xcode Testing Library
import XCTest
  1. Next add the Object you're planning on testing in setup:
private var ex : Example!
   override func setUp() {
	// Put setup code here. This method is called before the invocation of each test method in the class.
	self.ex = Example()
    }

here I am testing the class Example.
3. Write a test

/*
	For information on Unit Testing in Swift I found this website https://www.swiftbysundell.com/basics/unit-testing/
*/
    func testExample() {
        // This is an example of a functional test case.
        // Use XCTAssert and related functions to verify your tests produce the correct results.
		XCTAssert(ex.getExampleVal() == 10, "NOT 10")
    }

To run the test you can simply click on the diamond next to the function in Xcode or long click on the run button and click the test button.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant