<html><head><meta http-equiv="Content-Type" content="text/html charset=us-ascii"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class="">Hi Brian,<div class=""><br class=""><div><blockquote type="cite" class=""><div class="">On Dec 3, 2015, at 3:45 PM, Brian Gesiak &lt;<a href="mailto:modocache@gmail.com" class="">modocache@gmail.com</a>&gt; wrote:</div><br class="Apple-interchange-newline"><div class=""><div dir="ltr" class="">Hello! This is in reference to&nbsp;<a href="https://github.com/apple/swift-corelibs-xctest/pull/3" class="">https://github.com/apple/swift-corelibs-xctest/pull/3</a>. That pull request contains a commit that attempts to refactor XCTest such that it is more "unit-testable".<br class=""><br class="">To do so, it gives XCTMain an additional parameter: a list of objects conforming to the Reporter protocol. I think of this as a minimal, corelibs equivalent to Apple's XCTest's XCTestObserver.h. I say "minimal" because Reporter only defines Reporter.log(), whereas XCTestObserver has one method for each kind of test event (started, failed, finished, etc.).<br class=""><br class="">These reporters are, for now, storied in a global array. In the future, I'd like to discuss moving XCTest to a model in which all tests are (optionally) run in sub-processes, each of which may (optionally) run in parallel. This global array most certainly won't work for such a change, but for now, I simply want to have regression tests on the project. It's hard to send pull requests without knowing everything still works!<br class=""><br class="">Besides this approach, which modifies XCTest in order to test it, it may be more prudent to add tests *without* changing XCTest at all. To do so, I could add tests that run programs that call XCTMain(), then verify what's printed to stdout. This could be done using a Python script (which would go well with the build script, also in Python).<br class=""></div></div></blockquote><div><br class=""></div><div>It should be possible to use an out-of-process model that still uses XCTest itself to run the tests. For example, in the package manager we have some tests which spawn the package manager in order to test the end-to-end behavior. Ideally we would only do this for a small number of tests that really need this level of testing, and use unit testing for the rest.</div><div><br class=""></div><div>To be more concrete, what I am proposing here is that we have test cases which amount to:</div><div>--</div><div>class SomeTestCase : XCSelfTestCase {</div><div>&nbsp; func testFailure() {</div><div>&nbsp; &nbsp; &nbsp;withTestCase("Inputs/failing-test.swift") { results in</div><div>&nbsp; &nbsp; &nbsp; &nbsp;... check the results</div><div>&nbsp; &nbsp; &nbsp;}</div><div>&nbsp; }</div><div>}</div><div>--</div><div>where "Inputs/failing-test.swift" would be a checked in input file which has some expected behavior, and withTestCase() would be infrastructure (in XCSelfTestCase) which spawns a process to build and run that test, and then capture the output into a results object which could have further assertions run against it.</div><div><br class=""></div></div><div>&nbsp;- Daniel</div><div><br class=""><blockquote type="cite" class=""><div class=""><div dir="ltr" class=""><br class="">I'd love input on which of these approaches sounds more viable. Other ideas are also, of course, welcome!<br class=""><br class="">- Brian Gesiak</div>
<img src="https://u2002410.ct.sendgrid.net/wf/open?upn=AdkfTiApI80cNEyortTzHbERtY5det-2FDBvSxuhs4q2Ncjw3CkF0OEvMFiay9nTiNc5K0jbh4HjOkC-2B-2F8cAqW8O2o9tvsPk3e-2Bws1WX22U-2FPY4ha8Mfg83s8Z5O6o45QwY1eiLvNOJuTcmsoD5SegfzcW1T8KrX70AyZYjlxit711GBV9XeOhaXk3PvoJO0-2BbFIUZnq8iPU2hyF9QCZd-2FN21ZEKqEvnqlThZLMBOvzNg-3D" alt="" width="1" height="1" border="0" style="height:1px !important;width:1px !important;border-width:0 !important;margin-top:0 !important;margin-bottom:0 !important;margin-right:0 !important;margin-left:0 !important;padding-top:0 !important;padding-bottom:0 !important;padding-right:0 !important;padding-left:0 !important;" class="">
_______________________________________________<br class="">swift-corelibs-dev mailing list<br class=""><a href="mailto:swift-corelibs-dev@swift.org" class="">swift-corelibs-dev@swift.org</a><br class="">https://lists.swift.org/mailman/listinfo/swift-corelibs-dev<br class=""></div></blockquote></div><br class=""></div></body></html>