I want to create code that is not processed only when XCTest runs on swift.

Asked 2 years ago, Updated 2 years ago, 79 views

I am using XCTest.

For example, you would like to test the marker of funcaaa below.
Then, it will fall in tableView.reload.
By the way, tableView.reload does not affect the test results.

Therefore, only comment out tableView.reload during this test
This will allow you to run the test without any problems.

However, for other tests, tableView.reload is required.

That is, if you want to test funcaaa,
Comment out tableView.reload and
If you want to do other tests, you must comment out funcaaa
I can't.

Initialize TableView as it drops at TableView
Even if you read ViewDidLoad ( ) in the test setUp,
It falls off at TableView.delegate.

In this case, what are the options?

var marker=0
funcaaa(){
  marker = 1

  tableView.reload
}

=== test====
functestAAA(){
  aaaa Corporation
  XCTASertEqual (marker, 1, "")
}

swift test

2022-09-30 20:22

1 Answers

It is possible by using the compilation flag.
http://qiita.com/qmihara/items/a6b88b74fe64e1e05ca4

Only in this case, I think the labelView value has dropped because it contains nil.It may be resolved by substituting an instance.


2022-09-30 20:22

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.