0

i have installed scan to automate my testing process. i use the process from below website:http://qualitytesting.tumblr.com/post/141771752059/run-a-subset-of-xctest-tests-with-fastlanescan

I have two project one is ios and another is Osx which runs the ios project.

In the osx project, i init the scan file and there i add the scheme of ios project.

when i run the

scan 

command from terminal, it runs the ios project successfully.

But if i use below code:

class func shell(args: String...) -> Int32 {
    let task = NSTask()
    task.launchPath = "/usr/bin/env"
    task.arguments = args
    task.currentDirectoryPath = "/Users/username/Desktop/Xocde/mainSwiftAutomation/"
    task.launch()
    task.waitUntilExit()
    return task.terminationStatus
}

and than call the function like:

classname.shell("scan")

it shows the below error:

env: scan: No such file or directory

please help.

Eric Ipsum
  • 723
  • 3
  • 10
  • 24

2 Answers2

1

Scan will run if you change

task.launchPath = "/usr/bin/env"

to

task.launchPath = "/usr/local/bin/scan"

if your Scan is installed there instead. This was the problem on my machine.

The application is still unable to find xcpretty to generate the report, but my UI tests do run.

If you add the code with the shebang (#!/usr/bin/env swift) to a regular run_tests.swift file (rather than a Command Line Tool project), then you should be able to run it without problems from the command line:

$ swift run_tests.swift

...which is running the tests from Swift code but not through Xcode.

Oletha
  • 7,324
  • 1
  • 26
  • 46
  • thanks @Oletha for ur help... i have managed it in slight different way – Eric Ipsum Jun 21 '16 at 12:46
  • Glad you figured it out :) – Oletha Jun 21 '16 at 12:47
  • how u add shebang #!/usr/bin/env swift in ur swift code? if i add this line to my swift code, it shows an error. i am using swift 2.2 – Eric Ipsum Jun 23 '16 at 08:34
  • It will show an error if you are adding it as part of an Xcode project (I assume you have an OS X command line project), but if you save and run the file independently of the project, it will be fine. Run the file in Terminal using `swift yourFile.swift`. – Oletha Jun 23 '16 at 08:37
  • http://stackoverflow.com/questions/38435959/how-to-use-and-send-email-using-mime-in-swift pls help – Eric Ipsum Jul 18 '16 at 11:49
0

i have solved this like below:

i have create shell script where i use the scan command, than locate the shell script in my project folder and run it using my code.

But there i change my taskpath to

task.launchPath = "/usr/local/bin/scan"

and from command line, go to /usr/local/bin/scan and make it executable like below:

sudo chmod +x /usr/local/bin/scan

finally i run my shell script and it runs well.

Eric Ipsum
  • 723
  • 3
  • 10
  • 24