Note that there are some explanatory texts on larger screens.

plurals
  1. POSSL Connections Issues when running Unit Tests from the command line
    primarykey
    data
    text
    <h2>Goal</h2> <p>Our goal is to execute our Unit Tests within a Continuous Integration environment (<a href="http://jenkins-ci.org" rel="nofollow noreferrer" title="Jenkins CI">Jenkins</a>)</p> <p>(I believe it is essential for every question to state what exactly one is trying to achieve. Maybe the problem can actually be solved a very different way)</p> <h3>Update: More on "Why do you want to do this?"</h3> <p>Firstly, we are talking to specific, self-developed hardware. And I would like the Continuous <em>Integration</em> Test to tell me if anyone changed the behavior of the box without telling all the developers (Yes, yes, I know, such things <em>never</em> happen …)</p> <p>Secondly, some (not all) of our connections use certificates which are not valid by default, so we have code to check the validity of the certificate (<code>SecTrustEvaluate</code> etc.). Ideally of course, our tests would test that code, too. But that seems too much to ask.</p> <p>Thirdly: Well, why should I mock anything if I can have the real deal? The IDE has no issue with that, why should the command line.</p> <p>And if I wanted predictability, I'd return <code>YES</code> in all my tests ;) (and I <em>have</em> seen people do that). No, I want to know if the code actually and really works with our device. Is that some sort of perverted desire?</p> <h2>Problem resolved so far</h2> <p>Running tests from the command line sounds pretty straighforward, but</p> <pre><code>xcodebuild -sdk iphonesimulator ONLY_ACTIVE_ARCH=NO clean test </code></pre> <p>results in an ugly error:</p> <pre><code>unsupported build action 'test' </code></pre> <p>So I searched the web and found this article on <a href="http://www.raingrove.com/2012/03/28/running-ocunit-and-specta-tests-from-command-line.html" rel="nofollow noreferrer" title="Running OCUnit Tests from Command Line">Running OCUnit Tests from Command Line</a>.</p> <p>I followed all the steps, and I can run my tests from the command line like this:</p> <pre><code>xcodebuild -scheme CITests -sdk iphonesimulator TEST_AFTER_BUILD=YES ONLY_ACTIVE_ARCH=NO clean build </code></pre> <h2>Remaining Problem</h2> <p>However, now any NSURLConnection to an SSL Server will fail, because "The certificate for this server is invalid.". I have heared about keychain issues when running tests from the command line, but can this be true? Any SSL connection is refused?</p> <h2>To Reproduce</h2> <p>Get the sample at <a href="https://github.com/below/SSLTestDemo" rel="nofollow noreferrer">https://github.com/below/SSLTestDemo</a>. Open it up, and run the sample test using Xcode's own <strong>Test ⌘U</strong> command. The test should succeed.</p> <p>Now run the test on the command line:</p> <pre><code>xcodebuild -scheme CITests -sdk iphonesimulator TEST_AFTER_BUILD=YES ONLY_ACTIVE_ARCH=NO clean build </code></pre> <p>The test fails due to the "The certificate for this server is invalid." error.</p> <h2>Any Pointers?</h2> <ul> <li>Am I doing it wrong? </li> <li>Is this a genuine bug? </li> <li>If so, are there workaroungs?</li> </ul> <p>Any input is appreciated!</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload