Skip to content

assert_stderr and assert_stderr_line functions are not exported #95

Description

@Shurna83

Hello,
I am new to bats, and I am trying to create a very simple test case:

// file /ede/test/check-previous-deployments.bats
#!/usr/bin/env bats

# shellcheck disable=SC2317

setup() {
    bats_require_minimum_version 1.5.0
    bats_load_library bats-support
    bats_load_library bats-assert

    # only exports func `check_previous_deployment`, that logs to stderr if user aborts
    source "/ede/lib/check-previous-deployments.sh"
}

@test "testing bats" {
    # mocking user aborting 
    ask_yn_question() { return 1; }
    run --separate-stderr check_previous_deployment
    assert_failure 11
    assert_stderr_line --partial "[WARN] My warning message"
}

I run my test with Docker:

// file run-bats.sh
#!/bin/bash

set -eou pipefail

baseDir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
readonly baseDir

docker run -it \
	-v "$baseDir/test:/ede/test" \
	-v "$baseDir/lib:/ede/lib" \
	bats/bats:latest \
	/ede/test

Unfortunately, I am facing this error. This appears also when I try using assert_stderr.

$ ./run-bats.sh 
1..2
not ok 1 testing bats
# (in test file /ede/test/check-previous-deployment.bats, line 23)
#   `assert_stderr_line --partial "$stderr" "[WARN] My warning message" failed with status 127
# /ede/test/check-previous-deployment.bats: line 23: assert_stderr_line: command not found

Looking at the bats-assert repo, I noticed:

  1. In load.bash file, there is no sourcing of assert_stderr and assert_stderr_line
  2. I see tests for both assert_stderr and assert_stderr_line but don't find the functions in the src folder

I am running latest version of BATS Docker image, resulting in version

$ docker run -it bats/bats:latest --version
Bats 1.14.0

Have those methods been removed, and tests and docs are yet to be updated? Or am I missing something?

Thanks

EDIT: message typos

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions