0

I have a logout function that gets called during every tearDown(), but does not work when called this way. If I call the same logout function during the test, it works fine. I'm wondering what are the behaviors of XCUI testing during teardown, are there limitations? I tried debugging and calling app.swipeRight() using the lldb (espression->write code)...

-------
Navbar.swift
-------
import XCTest
import Foundation

class NavbarTest: XCTestCaseLib{  
    override func setUp() 
    {
       super.setUp()
       continueAfterFailure = false
    }
    override func tearDown() 
    {
       logout()
       super.tearDown()
    }

   func testSideBar_STAGING(){
     //...<test code that executes no problem>
     //...
   }
}



-----
XCTestCaseLib.swift
------
import XCTest
import Foundation

class XCTestCaseLib: XCTestCase {
let app = XCUIApplication()
func logout() {
    app.swipeRight()
    ...
}
bneely
  • 9,083
  • 4
  • 38
  • 46
1ak31sha
  • 501
  • 7
  • 18
  • Are you sure that the `tearDown()` function is executing? Add a log statement there to be sure. Also, does the behavior change if you call `self.logout()` instead of `logout()`? – bneely May 14 '16 at 21:03

1 Answers1

0

From the code you've posted, it appears to be your imports (I'm assuming here that these classes are in different files, otherwise your inheritance is ambiguous). If I'm mistaken please update your question to include your file structure. Play around with your imports and inheritance.

I believe you just need to import XCTest on your NavbarTest class

cakes88
  • 1,857
  • 5
  • 24
  • 33
  • Hi Thanks for taking the time to look at this. Ive updated the answer to include my imports and file names. This was not the problem. It seems today, that the logout function works when the testcase ends early(failed at some point), but if the test completes, then the teardown does not execute properly(i mean it executes, but swipe function cant seem to work)...super weird – 1ak31sha Apr 29 '16 at 18:29
  • You're not launching the app in `setup()`, is that intended? – cakes88 May 02 '16 at 15:07
  • Yes, i launch with different launch args in each test so i dont use setup for that. – 1ak31sha May 02 '16 at 21:49