kiwitcms / junit-plugin

JUnit plugin for Kiwi TCMS
http://kiwitcms.org
GNU General Public License v3.0
4 stars 5 forks source link

JUnit 5 plugin for Kiwi TCMS

Build Status Coverage Status TP for kiwitcms/junit-plugin (master) Maven Central Tidelift Become-a-sponsor Twitter

Installation & usage

Add this into your pom.xml:

<dependency>
    <groupId>org.kiwitcms.java</groupId>
    <artifactId>kiwitcms-junit-plugin</artifactId>
    <version>x.y.z</version>
</dependency>

This plugin extends org.junit.jupiter.api.extension.Extension and has junit.jupiter.extensions.autodetection.enabled=true configured by default in pom.xml. This means Jupiter will pick it up automatically.

You may alternatively decorate your test suite with the KiwiTcmsExtension class but that should be redundant:

import org.junit.jupiter.api.Test;
import static org.hamcrest.MatcherAssert.assertThat;

import org.junit.jupiter.api.extension.ExtendWith;
import org.kiwitcms.java.junit.KiwiTcmsExtension;

@ExtendWith(KiwiTcmsExtension.class)
public class KiwiJsonRpcClientTest {
    @Test
    public void yourTest(){
        assertThat(...);
    }
}

Configuration and environment

Minimal config file ~/.tcms.conf:

[tcms]
url = https://tcms.server/xml-rpc/
username = your-username
password = your-password

You can override the default file location by adding the Maven option tcmsConfigPath followed by the full path to a config file. For example: -DtcmsConfigPath=D:\Path\To\tcms.conf

For more info see tcms-api docs.

This plugin is only concerned with parsing the JUnit test results and reporting them to the backend. Behavior is controlled via environment variables.

For example this is how our own environment looks like::

#!/bin/bash

if [ "$TRAVIS_EVENT_TYPE" == "push" ]; then
    # same as $TRAVIS_TAG when building tags
    export TCMS_PRODUCT_VERSION=$TRAVIS_BRANCH
fi

if [ "$TRAVIS_EVENT_TYPE" == "pull_request" ]; then
    export TCMS_PRODUCT_VERSION="PR-$TRAVIS_PULL_REQUEST"
fi

export TCMS_BUILD="$TRAVIS_BUILD_NUMBER-$(echo $TRAVIS_COMMIT | cut -c1-7)"

For a more detailed example see: http://kiwitcms.org/blog/atodorov/2019/02/22/how-to-use-kiwi-tcms-plugins-pt-1/

Changelog

Files signed with EC1CEB7CDFA79FB5, Kiwi TCMS <info@kiwitcms.org>

12.5 (14 Jul 2023)

11.1 (14 Jul 2022)

11.0 (13 Dec 2021)

10.0 (02 Mar 2021)

This version works only with Kiwi TCMS v10.0 or later!

9.0 (15 Jan 2021)

This version works only with Kiwi TCMS v9.0 or later!

8.0 (09 Feb 2020)

This version works only with Kiwi TCMS v8.0 or later!

6.7.5 (10 Nov 2019)

Fixes moderate severity issue CVE-2019-16942, critical severity issue CVE-2019-16335 and critical severity issue CVE-2019-14540.

6.7.4 (06 July 2019)

6.7.3 (30 May 2019)

Fixes moderate severity issue CVE-2019-12086

6.7.2 (01 May 2019)

6.7.1 (15 April 2019)

6.7.0 (10 April 2019)

1.0.3 (21 March 2019)

Hacking

You need your ~/.m2/settings.xml to look something like this

<settings>
  <servers>
    <server>
      <id>ossrh</id>
      <username>kiwitcms-bot</username>
      <password>***</password>
    </server>
  </servers>

  <profiles>
    <profile>
      <id>ossrh</id>
      <activation>
        <activeByDefault>true</activeByDefault>
      </activation>
      <properties>
        <gpg.executable>gpg2</gpg.executable>
        <gpg.keyname>EC1CEB7CDFA79FB5</gpg.keyname>
      </properties>
    </profile>
  </profiles>
</settings>

To push a new release/SNAPSHOT update the version string in pom.xml and do

export GPG_TTY=$(tty)
mvn clean deploy -P release

NOTE: try ssh -X if Maven fails to start GnuPG. It needs to ask for a password which needs a terminal or X!

WARNING: consider setting junit.jupiter.extensions.autodetection.enabled=false im pom.xml if you are having problems building locally!

You will need Maven >= 3.3.9 which on RHEL/CentOS system can be obtained via SoftwareCollections:

scl enable rh-maven36 /bin/bash