Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Alamofire tests failing #1

Open
pietrocaselani opened this issue Dec 13, 2019 · 0 comments
Open

Alamofire tests failing #1

pietrocaselani opened this issue Dec 13, 2019 · 0 comments

Comments

@pietrocaselani
Copy link

pietrocaselani commented Dec 13, 2019

Hey!

I was showing your project to my team and I found some failing tests.

So, I cloned the project and ran the tests and some tests on AlamofireAsyncTests failed.
I notice that the failing tests are those that check for failing responses, with the message saying that expect TestError but got nil instead.

I tried to fix it with the code below

let testError = NSError(domain: "AsynchronousTests", code: 0, userInfo: nil)

func testDataRequestResponseFailure() {
    let expected = testError

    stub(everything, failure(expected as NSError))

    wait { expectation in
        Alamofire.request(fakeURL).response().async { result in
            switch result {
            case .success(let (_, _, value)):
                XCTFail("Unexpected value \(value)")
            case .failure(let actual):
                XCTAssertEqual(expected, actual.error as NSError)
            }
            expectation.fulfill()
        }
    }
}

but got this error

XCTAssertEqual failed: ("Error Domain=AsynchronousTests Code=0 "(null)"") is not equal to ("Error Domain=AsynchronousTests Code=0 "(null)" UserInfo={_NSURLErrorRelatedURLSessionTaskErrorKey=(
    "LocalDataTask <0063E615-BE9B-4022-AC07-1F06C14BDF97>.<1>"
), _NSURLErrorFailingURLSessionTaskErrorKey=LocalDataTask <0063E615-BE9B-4022-AC07-1F06C14BDF97>.<1>}")

So I think Mockingjay is returning another error or something like this. I looked at Mockingjay tests and here they are just verifying the error's domain.
Should we do the same maybe?

Also, I tried calling super.setUp here but the results were the same.

I running with this environment

Xcode 11.2.1
Build version 11B500

Could you please take a look at this?

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant