Skip to content

Instantly share code, notes, and snippets.

@PraveenKommuri
Created March 24, 2021 23:06
Show Gist options
  • Save PraveenKommuri/231e5bd79bb81f8567e616abc3a49f93 to your computer and use it in GitHub Desktop.
Save PraveenKommuri/231e5bd79bb81f8567e616abc3a49f93 to your computer and use it in GitHub Desktop.
Test your methods in playground through XCTestCase
import XCTest
// Sample class with one method in it.
class evenOddClass {
func isEvenNumber(_ number: Int) -> Bool {
if number % 2 == 0 {
return true
} else {
return false
}
}
}
// Sample test target class to check your functions.
class tests: XCTestCase {
var evenOddClassObj = evenOddClass()
func test1() {
XCTAssertEqual(evenOddClassObj.isEvenNumber(4), true)
}
func test2() {
XCTAssertEqual(evenOddClassObj.isEvenNumber(5), true)
}
}
tests.defaultTestSuite.run()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment