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
0 answers

How to take a screenshot in XCUITest during press&hold?

I need to take a screenshot in the middle of zoom/pan/rotate, i.e. I expect some code like this: element.startPressAndHold(.twoTouches) // at this point my app renders differently, so I capture a screenshot // for snapshot testing let shot =…
Paulius Liekis
  • 1,676
  • 3
  • 18
  • 26
0
votes
2 answers

How to set window size in XCUITest?

I want to do some screenshot-snapshot testing for my OSX application. For that obviously, I need the screenshots to be the same size every time. So how can I set the size of the main window of my application in XCUITests?
Paulius Liekis
  • 1,676
  • 3
  • 18
  • 26
0
votes
2 answers

Did not record an invocation in OCMStub/OCMExpect/OCMReject

I'm trying to mock a Singleton class in one of my unit tests. The way I'm creating my mock is like this: MySingletonController *mockController = OCMClassMock([MySingletonController class]); OCMStub([MySingletonController…
Jacobo
  • 1,259
  • 2
  • 19
  • 43
0
votes
1 answer

XCTest press and drag doesn't work when there's text underneath

I am trying to write a UI Test in Xcode for dragging a dot around the screen. The test had been working for weeks, but as soon as I put text behind the starting position of the dot, the UI Test is no longer able to drag the dot around (even though…
wristbands
  • 1,021
  • 11
  • 22
0
votes
0 answers

iOS Programming in Swift and memory management

I'm fairly new to iOS swift programing. I'm currently working on a project of mine and have been very careful to only capture weak references to self, check that deinit is called etc. But I've noticed that the memory indicator in the Debug…
Anthony
  • 720
  • 1
  • 6
  • 24
0
votes
1 answer

Why there is a new instance of object between unit tests in the same XCTestCase?

I have created test class like this: import XCTest class ExampleTests: XCTestCase { private let context = NSManagedObjectContext.mr_() func testA() { print(#function) print(context) XCTAssertTrue(true) } …
Bartłomiej Semańczyk
  • 59,234
  • 49
  • 233
  • 358
0
votes
1 answer

How can set accessibility identifier in attributedPlaceholder

I have the given piece of code textField.attributedPlaceholder = NSAttributedString(string: Strings.test, attributes: [NSAttributedString.Key.foregroundColor: ColorTheme.test]) How I can…
Straider
  • 13
  • 2
0
votes
1 answer

Write xctest for function inside an operation queue

I have a function as follows which adds an operation to the operation queue, how do I test the block of code that is being added to the operation queue, I tried using an expectation by passing an analytics observer spy and check if the value is set…
marilyn
  • 191
  • 3
  • 3
  • 17
0
votes
1 answer

XCT assert case of enum

I'd like to assert whether a value is a specific enum case. For example, if I have the following enum class, and a variable let value: MyEnum: enum MyEnum { case firstCase(value: Int) case secondCase } I'd like to check whether value is an…
nhaarman
  • 98,571
  • 55
  • 246
  • 278
0
votes
0 answers

Objective c: XCTest with Core data class

I have a custom Core Data class called User, but when I tried to import the User+CoreDataClass.h file in my XCTest, it says that the file is not found, and it does not even show up. I have tried to search but most of the results are for Swift and…
Beck
  • 5
  • 3
0
votes
1 answer

Write test cases to test enum-based analytics system dynamically using XCTest

I just started writing tests using XCTest, I have to write test cases to test if the right analytics event is passed, the analytics system has enum based events something like this. enum AnalyticsEvent { case loginScreenViewed case…
marilyn
  • 191
  • 3
  • 3
  • 17
0
votes
0 answers

XCUITests fail on m1 Mac: mach-o, but wrong architecture

I have a perfectly fine running UITest target in my app that runs fine on the Intel based old Mac. If I take the pull of this same code in my M1 Mac, the UITests fail even before execution. The app is launched when the test is ran but it ends up in…
nr5
  • 4,228
  • 8
  • 42
  • 82
0
votes
1 answer

How to do basic testing in a SwiftUI project?

I have this super basic app which changes the colour of a circle when you press a button: struct ContentView: View { @State private var color: Color = .red var body: some View { VStack { Circle() …
rayaantaneja
  • 1,182
  • 7
  • 18
0
votes
0 answers

How to write test in swift for image loaded from URL using XCTEST?

I am just starting with writing test cases for my code, I wanted to write test cases to test if the right image is loaded from the URL and also has cache implemented within in swift using XCTEST. Code to test func loadImageUsingUrlString(urlString:…
marilyn
  • 191
  • 3
  • 3
  • 17
0
votes
0 answers

XCTest failing even after fulfilling expectation

I have a task aggregator which aggregates and executes tasks in a synchronized manner. It's thread safe and all that. Here's what it looks like class DaddysMagicalTaskAggregator { private let tasks: ThreadSafeValueContainer<[KewlTask]> private…
Singh Raman
  • 103
  • 1
  • 5