Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Xcode does not recognize new test functions

I've just started writing unit tests and I've encountered an issue. So far I've dug through different blogs on google and stackoverflow but I haven't been able to resolve this.

Every time I write a function to be tested the run button (shaped like a diamond) does not appear. The only run buttons that do show up are the default functions created by Xcode when you create a new unit test target.

Here's an example of the issues.

Xcode screenshot

Could it be a bug or am I missing something?

like image 352
B.Harrison Avatar asked Mar 20 '18 21:03

B.Harrison


People also ask

How do I add tests to Xcode?

To add a unit test target to an existing Xcode project, choose File > New > Target. Select your app platform (iOS, macOS, watchOS, tvOS) from the top of the New Target Assistant. Select the Unit Testing Bundle target from the list of targets.

How does Xcode measure test coverage?

To measure and visualize code coverage for a project, follow these steps: Enable code coverage date gathering. To do this, go to Product › Scheme › Edit Scheme... , and select Test from the left hand side menu. Under the Info section, check the Gather coverage data box.

What is XCTest XCUITest?

Key Concepts of XCUITest XCTest: XCTest is a testing framework that allows you to create and run UI tests, unit tests, and performance tests for your Xcode projects in Swift and Objective-C languages. It is pre-built with Xcode.


1 Answers

test needs to be on the front of the function signature. ie: test"functionName"()

like image 168
SirCJ Avatar answered Sep 28 '22 18:09

SirCJ