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

Already on GitHub? Sign in to your account

KIF_SCREENSHOTS not working from CLI #160

Closed
jcderr opened this Issue Oct 22, 2012 · 12 comments

Comments

Projects
None yet
3 participants

jcderr commented Oct 22, 2012

We don't seem to get screenshots generated when we run the tests through our CI system.

I've tried setting KIF_SCREENSHOTS when running xcodebuild, when running RunTests.sh, and both. But to no avail.

dimaj commented Oct 22, 2012

This works for me with Jenkins.
I'm setting KIF_SCREENSHOTS by using: 'export KIF_SCREENSHOTS="/path/to/screenshots/folder"

jcderr commented Oct 22, 2012

$ mkdir screens
$ export KIF_SCREENSHOTS="${PWD}/screens"
$ xcodebuild -target "Integration Tests" -config Release -sdk iphonesimulator -arch i386 VALID_ARCHS=i386
[ ... ]
$ ./RunTests.sh
[ ... ]
2012-10-22 13:48:26.763 Testable (Integration Tests)[2294:c07] *** KIF TESTING FINISHED: 1 failures
$ ls -la screens
total 0
drwxr-xr-x 2 jcderr staff 68 Oct 22 13:41 .
drwxr-xr-x 10 jcderr staff 340 Oct 22 13:41 ..

Our RunTests is basically yours, but we run xcodebuild elsewhere, and allow a user to set the Target with an ENV var.

dimaj commented Oct 23, 2012

try putting your exports in the RunTests.sh file... It is possible that every script file has its own environment.

jcderr commented Oct 23, 2012

I'm already calling it with:

KIF_SCREENSHOTS="the/directory/path" waxsim [ ... etc ... ]

in the script. 'export' will just ensure the setting trickles back up to
the shell after it's run. but i'll give it a shot anyway for completeness.

On Mon, Oct 22, 2012 at 10:33 PM, Dmitry Jerusalimsky <
notifications@github.com> wrote:

try putting your exports in the RunTests.sh file... It is possible that
every script file has its own environment.


Reply to this email directly or view it on GitHubhttps://github.com/square/KIF/issues/160#issuecomment-9689728.

Jeremy Derr

m › 512.426.0702

dimaj commented Oct 23, 2012

So, our build is set up like so:
Jenkins CI with XCode extension that performs compile of the product
Shell Script like this:

mkdir ${WORKSPACE}/FailedScreenshots
export KIF_SCREENSHOTS=${WORKSPACE}/FailedScreenshots

OUT_FILE=${WORKSPACE}/KIF-$$.out
MOVIE=${WORKSPACE}/KIF-$$.mov
APP="${WORKSPACE}/output/MyApp.app"
WAXSIM=/Users/Shared/waxsim

#Run the app we just built in the simulator and send its output to a file
echo "Running KIF tests"
$WAXSIM -f "iphone" -s 5.1 -v $MOVIE "$APP" > $OUT_FILE 2>&1

Hope this helps.

jcderr commented Nov 7, 2012

Still not working for me; here's the failure we're seeing. Perhaps it's not something that generates a screenshot?

2012-11-07 10:04:04.849 UI Tests[7561:c07] FAIL (10.01s): Wait for view with accessibility label "ALabelThatDoesNotExist"
2012-11-07 10:04:04.849 UI Tests[7561:c07] FAILING ERROR: Error Domain=KIFTest Code=0 "The step timed out after 10.00 seconds." UserInfo=0xfcdfec0 {NSUnderlyingError=0xfcdfea0 "Waiting for presence of accessibility element with label "ALabelThatDoesNotExist"", NSLocalizedDescription=The step timed out after 10.00 seconds.}

dimaj commented Nov 7, 2012

I'm assuming that screenshots are working outside of jenkins, right?
Try adding 'env' command after your 'export'

i.e.

mkdir ${WORKSPACE}/FailedScreenshots
export KIF_SCREENSHOTS=${WORKSPACE}/FailedScreenshots
env
ls

see if both FailedScreenshots folder has been created and KIF_SCREENSHOTS has been exported.

jcderr commented Nov 7, 2012

On another project, it was working in Xcode but not on the CLI. On this particular project though, it's not working in Xcode directly, either, it seems.

I've verified that KIF_SCREENSHOTS is being exported and is in the env in both Xcode and in the RunTests.sh script I'm using.

dimaj commented Nov 7, 2012

Interesting...

Stupid question... Are you sure that your screenshots folder exists? Default implementation of KIF skips screenshot creation if folder does not exist. If you'll look at my form of KIF, you can merge my file dimaj/KIF@0a84f69
This commit changes behavior of screenshots. If folder does not exist, it will get created. Also, it names screenshot files in a form of "date - description of step.png"

jcderr commented Nov 7, 2012

It exists; and we figured it out. The environment var needs to be set
before COMPILE time, not before run time.

On Wed, Nov 7, 2012 at 10:55 AM, Dmitry Jerusalimsky <
notifications@github.com> wrote:

Interesting...

Stupid question... Are you sure that your screenshots folder exists?
Default implementation of KIF skips screenshot creation if folder does not
exist. If you'll look at my form of KIF, you can merge my file dimaj/KIF@
0a84f69dimaj/KIF@0a84f69
This commit changes behavior of screenshots. If folder does not exist, it
will get created. Also, it names screenshot files in a form of "date -
description of step.png"


Reply to this email directly or view it on GitHubhttps://github.com/square/KIF/issues/160#issuecomment-10155649.

Jeremy Derr

m › 512.426.0702

dimaj commented Nov 7, 2012

Really?

In our case, we have 2 jenkins jobs: compile and run. The environment variable is set at runtime and it works...

Contributor

bnickel commented Sep 16, 2013

Closing in favor of #247.

@bnickel bnickel closed this Sep 16, 2013

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment