Coder Social home page Coder Social logo

allegro / swift-junit Goto Github PK

View Code? Open in Web Editor NEW
29.0 4.0 13.0 288 KB

A Swift library for creating JUnit XML test results that can be interpreted by tools such as Bamboo or Jenkins. Macos and Linux ready.

License: Apache License 2.0

Makefile 2.17% Swift 97.83%
swift server-side-swift xml junit xctest-linux xctest junit-report junit-xml

swift-junit's Introduction

Swift Test Reporter

CI

A Swift library for creating JUnit XML test results that can be interpreted by tools such as Bamboo or Jenkins.

Sample output:

<?xml version="1.0" encoding="UTF-8"?>
<testsuites>
  <testsuite tests="2" failures="0" disabled="0" errors="0" time="0.0013051033020019531" name="JUnitReporterTests">
    <testcase classname="SwiftTestReporterTests.JUnitReporterTests" name="testReporterShouldReturnXMLForEmptySuite" time="0.0007890462875366211"></testcase>
    <testcase classname="SwiftTestReporterTests.JUnitReporterTests" name="testReporterShouldReturnXMLForFailedTest" time="0.000516057014465332"></testcase>
  </testsuite>
  <testsuite tests="1" failures="1" disabled="0" errors="0" time="0.00021898746490478516" name="UtilsTests">
    <testcase classname="SwiftTestReporterTests.UtilsTests" name="testShouldReturnProperlyClassName" time="0.00021898746490478516">
      <failure message="Oh no!!"></failure>
    </testcase>
  </testsuite>
</testsuites>

How to use it?

Linux

Add SwiftTestReporter to Package.swift:

import PackageDescription

let package = Package(
  dependencies: [
    ...
    .package(url: "https://github.com/allegro/swift-junit.git", from: "2.0.0"),
    // or for Swift 4.x
    // .package(url: "https://github.com/allegro/swift-junit.git", from: .upToNextMajor(from: "1.0.0")),
                
  ]
  ...
  targets: [
    ...
    .testTarget(
      name: "AppTests",
      dependencies: [
        "App",
        "SwiftTestReporter"
      ]
    ),
  ]
)

Next, add:

import SwiftTestReporter

_ = TestObserver()

To LinuxMain.swift. Done.

XCode

In Project Navigator, select particular project:

test

Next, select test target:

test

Add a new property named Principal class and set it to SwiftTestReporter.TestObserver

test

swift-junit's People

Contributors

ar4s avatar aufflick avatar code28 avatar foscomputerservices avatar kam800 avatar mkuzmik avatar vi4m avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

swift-junit's Issues

Test xml.file is not generated

Hi, I am working on a Mac and I am building a plain Swift project (no Xcode project).
I've done all steps in the Readme (without the steps for Xcode, as it is no Xcode project) but no test.xml file is getting generated. What am I doing wrong or where can I find the generated junit xml-file?

I am doing the following:

swift build
Fetching https://github.com/alexaubry/HTMLString.git
Fetching https://github.com/allegro/swift-junit.git
Cloning https://github.com/alexaubry/HTMLString.git
Resolving https://github.com/alexaubry/HTMLString.git at 5.0.0
Cloning https://github.com/allegro/swift-junit.git
Resolving https://github.com/allegro/swift-junit.git at 2.0.0

swift test
...
Test Suite 'All tests' passed at 2020-11-02 14:52:15.834.
         Executed 2 tests, with 0 failures (0 unexpected) in 0.086 (0.086) seconds

This is my Package.swift:

// swift-tools-version:5.2
// The swift-tools-version declares the minimum version of Swift required to build this package.

import PackageDescription

let package = Package(
    name: "swiftExercise",
    dependencies: [
        .package(name: "SwiftTestReporter", url: "https://github.com/allegro/swift-junit.git", from: "2.0.0"),
    ],
    targets: [
        .target(name: "swiftExerciseLib"),
        .target(name: "swiftExerciseApp", dependencies: ["swiftExerciseLib"]),
        .testTarget(name: "swiftExerciseTests", dependencies: ["swiftExerciseLib", "SwiftTestReporter"]),
    ]
)

My Swift version: Apple Swift version 5.2.2 (swiftlang-1103.0.32.6 clang-1103.0.32.51)

Please tag version 2.0.1

Thanks @vi4m for merging my PRs. If you think it's stable enough, it would be great to tag version 2.0.1 so that spm can pull this in with a version tag.

I've verified the change off the master branch in my CI.

Upgrade

Test on the newest Swift (5.9) - upgrade CI Matrix.
Upgrade deprecated methods.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.