ginkgo

package module
v0.0.0-...-0b7126b Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 20, 2024 License: Apache-2.0, BSD-3-Clause Imports: 7 Imported by: 0

README

Datadog SDK for Ginkgo testing

This SDK is part of Datadog's CI Visibility sdk.

Current state of the project

This project does not currently support pending or focused specs. This is a known issue and we are working on it.

Getting Started

Installing

Installation of the Datadog Go testing SDK is done via go get:

go get -u github.com/DataDog/dd-sdk-go-testing/ginkgo
Instrumenting your tests

To instrument tests that use Ginkgo v2 package, you have to call Run(m) in your TestMain function, and replace the github.com/onsi/ginkgo/v2 import with github.com/DataDog/dd-sdk-go-testing/ginkgo:

For example:

package go_sdk_sample

import (
	"os"
	"testing"

	. "github.com/DataDog/dd-sdk-go-testing/ginkgo"
)

func TestMain(m *testing.M) {
	os.Exit(Run(m))
}

// This test will be instrumented
func TestSimpleExample(t *testing.T) {
	RegisterFailHandler(Fail)
	RunSpecs(t, "Reader Suite")
}

// Test example from https://onsi.github.io/ginkgo/#spec-subjects-it
var _ = Describe("Books", func() {
  It("can extract the author's last name", func() {
    book = &books.Book{
      Title: "Les Miserables",
      Author: "Victor Hugo",
      Pages: 2783,
    }

    Expect(book.AuthorLastName()).To(Equal("Hugo"))
  })
})

Configuration

The sdk can be configured the same way as the Datadog Go tracing library.

License

This work is part of the Datadog Go testing SDK and inherits its license.

Documentation

Index

Examples

Constants

View Source
const GINKGO_VERSION = ginkgo.GINKGO_VERSION + "+dd-trace-go"
View Source
const TestFrameworkName = "github.com/onsi/ginkgo/v2"

Variables

View Source
var AbortSuite = ginkgo.AbortSuite
View Source
var Fail = ginkgo.Fail
View Source
var GinkgoConfiguration = ginkgo.GinkgoConfiguration
View Source
var GinkgoParallelProcess = ginkgo.GinkgoParallelProcess
View Source
var GinkgoRandomSeed = ginkgo.GinkgoRandomSeed
View Source
var GinkgoRecover = ginkgo.GinkgoRecover
View Source
var GinkgoT = ginkgo.GinkgoT
View Source
var GinkgoWriter = ginkgo.GinkgoWriter
View Source
var PauseOutputInterception = ginkgo.PauseOutputInterception
View Source
var ResumeOutputInterception = ginkgo.ResumeOutputInterception
View Source
var Skip = ginkgo.Skip

Functions

func AfterAll

func AfterAll(args ...interface{}) bool

func AfterEach

func AfterEach(args ...interface{}) bool

func AfterSuite

func AfterSuite(userFunc func()) bool

func BeforeAll

func BeforeAll(args ...interface{}) bool

func BeforeEach

func BeforeEach(args ...interface{}) bool

func BeforeSuite

func BeforeSuite(userFunc func()) bool

func By

func By(text string, callback ...func())

func Context

func Context(text string, callback ...interface{}) bool

func DeferCleanup

func DeferCleanup(args ...interface{})

func Describe

func Describe(text string, callback ...interface{}) bool

func FContext

func FContext(text string, callback ...interface{}) bool

func FDescribe

func FDescribe(text string, callback ...interface{}) bool

func FIt

func FIt(text string, callback ...interface{}) bool

func FSpecify

func FSpecify(text string, callback ...interface{}) bool

func FWhen

func FWhen(text string, callback ...interface{}) bool

func It

func It(text string, callback ...interface{}) bool

func JustAfterEach

func JustAfterEach(args ...interface{}) bool

func JustBeforeEach

func JustBeforeEach(args ...interface{}) bool

func PContext

func PContext(text string, callback ...interface{}) bool

func PDescribe

func PDescribe(text string, callback ...interface{}) bool

func PIt

func PIt(text string, callback ...interface{}) bool

func PSpecify

func PSpecify(text string, callback ...interface{}) bool

func PWhen

func PWhen(text string, callback ...interface{}) bool

func Run

func Run(m *testing.M, opts ...tracer.StartOption) int

Run is a helper function to run a `testing.M` object and gracefully stopping the tracer afterwards

func RunSpecs

func RunSpecs(t ginkgo.GinkgoTestingT, description string, args ...interface{}) bool
Example
t := &testing.T{} // Get t from parameter

Describe("Books", func() {
	It("can guess the category", func() {
		book := &books.Book{
			Title:  "Les Miserables",
			Author: "Victor Hugo",
			Pages:  2783,
		}

		Expect(book.CategoryByLength()).To(Equal("NOVEL"))

		fmt.Println("This is a novel!")
	})
})

RegisterFailHandler(Fail)
RunSpecs(t, "Example Suite")
Output:

This is a novel!

func Specify

func Specify(text string, callback ...interface{}) bool

func SynchronizedAfterSuite

func SynchronizedAfterSuite(allProcessBody func(), process1Body func()) bool

func SynchronizedBeforeSuite

func SynchronizedBeforeSuite(process1Body func() []byte, allProcessBody func([]byte)) bool

func When

func When(text string, callback ...interface{}) bool

func XContext

func XContext(text string, callback ...interface{}) bool

func XDescribe

func XDescribe(text string, callback ...interface{}) bool

func XIt

func XIt(text string, callback ...interface{}) bool

func XSpecify

func XSpecify(text string, callback ...interface{}) bool

func XWhen

func XWhen(text string, callback ...interface{}) bool

Types

type GinkgoTInterface

type GinkgoTInterface = ginkgo.GinkgoTInterface

type GinkgoTestingT

type GinkgoTestingT = ginkgo.GinkgoTestingT

type GinkgoWriterInterface

type GinkgoWriterInterface = ginkgo.GinkgoWriterInterface

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL