[swift-evolution] Language or XCTest improvements to allow testing assert/precondition failures
daniel_dunbar at apple.com
Sun Dec 13 11:23:50 CST 2015
> On Dec 13, 2015, at 2:03 AM, David Hart via swift-evolution <swift-evolution at swift.org> wrote:
> Currently, it is impossible for XCTest to unit test assert and precondition failures because they kill the process. And those are important to unit test: how would you test NSArray's objectAtIndex bound conditions? Currently, the standard library tests those with StdlibUnittest, a small piece of code which runs those tests in a forked process.
> I want to start a proposal but I'm not sure if it should come as a XCTest improvement which spawns a process or if the language should implement assert and precondition as a special kind of throw?
One way to start a proposal is to try and work through what the implications of each approach are, decide which is best, and then write that up in a proposal explaining why you chose the approach you did.
If you are interested in working on this, I would definitely also survey how other frameworks do this. Googletest, for example, supports this via a "death tests" mechanism, which would be good to understand and compare to:
I suspect that spawning a process is the best approach, because it can cover more cases than the language built in features, and doesn't require language support, but I would be interested in seeing an in depth study of what this would mean for the framework and the APIs.
> swift-evolution mailing list
> swift-evolution at swift.org
More information about the swift-evolution