Skip to content
This repository has been archived by the owner on Apr 29, 2021. It is now read-only.

Add debug output to result #4

Closed
sven opened this issue Jan 15, 2013 · 2 comments
Closed

Add debug output to result #4

sven opened this issue Jan 15, 2013 · 2 comments

Comments

@sven
Copy link

sven commented Jan 15, 2013

Hi Sam,

I'm currently using bats but have no idea how to dig deeper in a test case when something goes wrong.

Example testcase:

    @test "build documentation" {
        [ -d "doc_dir/" ]
        pushd doc_dir/
        [ -e "Makefile" ]
        make
        [ -e "documentation.pdf" ]
        popd
    }

So if any of the above fails, I only see that the test fails and need to debug the failing line by hand. In bash I can do a set -x to see the lines as they are executed. Is it possible to do something like this in bats?

Thanks
Sven

@sstephenson
Copy link
Owner

Bats will now tell you the test filename and line number that triggers the failure: bc72b85

@JohannesFKnauf
Copy link

Recently we wanted to conveniently enable debug out of the full output of run commands in tests. We did not find a really satisfying solution, but stumpled upon this issue immediately. So adding for all the lost souls with the same problem:

We worked around it by adding some debug code to the teardown() { } function, which has all necessary variables in scope.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants