Questions tagged [xctest]

XCTest is an Apple-provided framework which implements unit testing functions. It works with iOS 7 and all versions of OS X.

XCTest is a testing framework initially released with Xcode 5, provides a common framework for writing unit tests. XCTest supports unit testing for iOS, IPadOS, tvOS, watchOS, and macOS projects.

XCTest is part of the following SDKs:

  • Xcode 5.0 and later.

References

1962 questions
0
votes
1 answer

Weird math operator when unit test

I'm trying to write unit test for this simple function: /// Rotate the coordinate of CGPoint (as Vector) by radian angle /// https://matthew-brett.github.io/teaching/rotation_2d.html func rotateCoordinate(by alpha: CGFloat) -> CGPoint { //…
Eddie
  • 1,903
  • 2
  • 21
  • 46
0
votes
1 answer

How to fix wait for app to idle in XCUITest

In my UI test, I sometimes get the Wait for app to idle message in the console. Usually, it's not that often, but now, it always appears and makes the test fails on my mac. This is what I have done so far: Disabling/enabling animation didn't…
0
votes
0 answers

XCTest hangs indefinitely partway through running tests

When I run my complete tests: (command u), partway through, they hang. I'm not aware of any infinite loops or any other way this would be triggered. While it appears to hang on testMatrixToCsv(), when I comment out the body of this method, it still…
ScottyBlades
  • 12,189
  • 5
  • 77
  • 85
0
votes
1 answer

XCTest class func setUp() method how to handle failures

So Apple has an example of how the setUp and TearDown methods should be used that looks like this: class SetUpAndTearDownExampleTestCase: XCTestCase { override class func setUp() { // 1. // This is the setUp() class method. …
sago92
  • 51
  • 6
0
votes
0 answers

How can I test the full setup of an iOS app?

My iOS app (Swift 5.3) has the structure below for the API and unit testing via mocking. This does allow to test some aspects with a mocked-up API, but it's not a complete test: When running the tests, I will still run setupInitialStateForApp…
cgold
  • 4,075
  • 1
  • 12
  • 13
0
votes
1 answer

How to check background color of the XCUIElement in UI test cases??

I am working on one issue where I need to change the Textfield's background color to the white color. I wanted to add the UI test case for it to check if background color of the XCUIElement(i.e Textfield) is white color or not. I searched for it but…
Jarvis The Avenger
  • 2,750
  • 1
  • 19
  • 37
0
votes
0 answers

How to unit test in XCTest auto layout exceptions that are dynamic?

When a test is running and it detects an auto layout exception it should fail it. What I don't want to do is assert against a specific value. For example I don't want to do this: XCTAssertEqual(view.bounds.height, 200.0)
0
votes
1 answer

OCMock test if method does nothing but is called

Using OCMock, how do I test if a method does nothing? - (void)myMethod:(BOOL)active { if (active) { // Set property or do whatever } // Do nothing -- I need to test this scenario }
h.and.h
  • 690
  • 1
  • 8
  • 26
0
votes
1 answer

Testing UserDefaults values in UiTests or UnitTests

I am saving an Int in UserDefaults and this is reduced by one by clicking a button. I don't know if that is important but I have added an extension to UserDefaults to load an initial value if the app starts for the first time: extension UserDefaults…
L3n95
  • 1,505
  • 3
  • 25
  • 49
0
votes
1 answer

Failed to prevent system sleep during UI testing. Error code: -536870211

When I try to run my unit tests I'm getting this error. It's weird because I have no UI tests. Quitting Xcode and restarting doesn't work.
ScottyBlades
  • 12,189
  • 5
  • 77
  • 85
0
votes
0 answers

What is the order of unit test cases in XCode 12?

Note: Answers to similar, existing questions are unfortunately hopelessly outdated and based on older versions of XCode. I created this question because I could not find an answer that was later than 2016. As of XCode 12, the default test scheme is…
Winston Du
  • 340
  • 2
  • 9
0
votes
1 answer

Why Code coverage ribbon is not visible on Source editor?

I have integrated Unit test in my project. I have enabled code coverage from Xcode->Editor->CodeCoverage. From App schemes-> Test->Options->Checked Gatherd coverage for my app target. As you can see in above image i have added unit test cases…
Jack
  • 13,571
  • 6
  • 76
  • 98
0
votes
0 answers

Xcode Is it possible to create a UITest project only for a given received IPA file?

I would like to hire a UITester for a iOS app. I would like that he write automated tests with Xcode but I don't want to share my project with him. So my idea is to send him an app file. I have tested my idea with Xcode but I am blocked by an error…
Blazej SLEBODA
  • 8,936
  • 7
  • 53
  • 93
0
votes
1 answer

How to dismiss Alert in XCTestCase

class ProfileVC: BaseUIVC { var dispatchGroupHelper: DispatchGroupImpl var isFlag: Bool init(dispatchGroupHelper: DispatchGroupImpl = DispatchGroupHelper(), isFlag: Bool = false) { self.dispatchGroupHelper = dispatchGroupHelper …
0
votes
1 answer

XCTest copy file from phone

Hello I'm writing XCTests in swift. I need some additional test information that does not fit into to the XCResults. I'm currently writing this to a file on the physical device that's being tested. What I would like to do is at the end of all tests…
sago92
  • 51
  • 6
1 2 3
99
100