Skip to content

[SR-5262] XCTest should have a way to validate assertions (e.g. assert()) #370

Open
@phausler

Description

@phausler
Previous ID SR-5262
Radar None
Original Reporter @phausler
Type New Feature
Additional Detail from JIRA
Votes 0
Component/s XCTest
Labels New Feature
Assignee None
Priority Medium

md5: 45492463837a5115b54a5e4cdffbc273

Issue Description:

Often times when testing code it is helpful to validate assertion cases that have preconditions or fatalErrors. A method that would aide in this endeavor would be something along the lines of XCTAssertIsFatal where a block of code is passed in that is expected to trigger a fatalError.

Normally this would mean that the code would crash. However if a signal handler for SIGILL is installed we can validate if an assertion is tripped.

See https://github.com/phausler/swift-corelibs-xctest/tree/assert_fatal for a rough draft at handling fatal assertions (note this only works in a non attached debugger mode and has only been written for Darwin, however a linux port should be trivial)

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions