Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings
This repository was archived by the owner on Oct 17, 2021. It is now read-only.
/TAPPublic archive

A Swift package for the Test Anything Protocol (v13)

NotificationsYou must be signed in to change notification settings

SwiftDocOrg/TAP

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

22 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

A Swift package for theTest Anything Protocol (v13).

Requirements

  • Swift 5.3+

Usage

You can useTAP as an alternative toXCTest in executable targetsor as a custom reporter in test targets.

Running Tests Directly

import TAPtryTAP.run([test(1+1==2), // passestest(true==false) // fails])// Prints:/*TAP version 131..2ok 1not ok 2  ---  file: path/to/File.swift  line: 5  ...  */

Custom Test Reporting

Linux

Swift Package Manager on Linuxusesswift-corelibs-xctest,which provides anXCTMain that

Run the following commandon macOS to (re)-generate your main test file:

$ swift test --generate-linuxmain

Open the resultingLinuxMain.swift file,add an import statement for theTAP moduleand registerXCTestTAPObserver as a test observer.In Swift 5.4 and later,you can update theXCTMain invocation to include anobservers parameterwith an instance ofXCTestTAPObserver.

#if os(Linux)import XCTestimport TAP@testableimport TAPTests#if swift(>=5.4)XCTMain([testCase(TAPTests.allTests)],arguments:CommandLine.arguments,observers:[XCTestTAPObserver()])#elseXCTestObservationCenter.shared.addTestObserver(XCTestTAPObserver())XCTMain([testCase(TAPTests.allTests)])#endif

When you run theswift test command,your test suite will be reported in TAP format.

macOS and iOS

As of Swift 5.3,it's not possible to configure a custom reporterwhen running tests directly through Swift Package Manager.However, Xcode provides a mechanism for loading custom reports viaXCTestObservationCenter.

Create a new file namedTestObservation.swift and add it to your test bundle.Import theTAP module,declare a subclass ofNSObject namedTestObservation,and override its designated initializerto registerXCTestTAPObserver with the sharedXCTestObservationCenter.

import TAPfinalclassTestObservation:NSObject{overrideinit(){XCTestObservationCenter.shared.addTestObserver(XCTestTAPObserver())}}

Add an entry to your test target'sInfo.plist filedesignating the fully-qualified name of this class as theNSPrincipalClass.

    <key>NSPrincipalClass</key>    <string>YourTestTarget.TestObservation</string>

When you run your test bundle,Xcode will instantiate the principle class first,ensuring that your test observers are registered in timeto report the progress of all test runs.

Installation

Swift Package Manager

Add the TAP package to your target dependencies inPackage.swift:

import PackageDescriptionletpackage=Package(  name:"YourProject",  dependencies:[.package(        url:"https://github.com/SwiftDocOrg/TAP",        from:"0.2.0"),])

AddTAP as a dependency to your test target(s):

targets:[.testTarget(    name:"YourTestTarget",    dependencies:["TAP"]),

License

MIT

Contact

Mattt (@mattt)

About

A Swift package for the Test Anything Protocol (v13)

Topics

Resources

Stars

Watchers

Forks

Packages

No packages published

Contributors2

  •  
  •  

Languages


[8]ページ先頭

©2009-2025 Movatter.jp