From 098d993eb43f42d651d531fad5b4178ad96fe29e Mon Sep 17 00:00:00 2001 From: Sam Stephenson Date: Wed, 28 Dec 2011 20:23:52 -0600 Subject: [PATCH] Test that each test's environment is isolated --- test/bats.bats | 5 +++++ test/fixtures/environment.bats | 8 ++++++++ 2 files changed, 13 insertions(+) create mode 100644 test/fixtures/environment.bats diff --git a/test/bats.bats b/test/bats.bats index 5f5b510..0eec271 100755 --- a/test/bats.bats +++ b/test/bats.bats @@ -41,3 +41,8 @@ FIXTURE_ROOT="$BATS_TEST_DIRNAME/fixtures" [ ${lines[1]} = "not ok 1 a failing test" ] [ ${lines[2]} = "ok 2 a passing test" ] } + +@test "test environments are isolated" { + run bats "$FIXTURE_ROOT/environment.bats" + [ $status -eq 0 ] +} diff --git a/test/fixtures/environment.bats b/test/fixtures/environment.bats new file mode 100644 index 0000000..8d3b984 --- /dev/null +++ b/test/fixtures/environment.bats @@ -0,0 +1,8 @@ +@test "setting a variable" { + variable=1 + [ $variable -eq 1 ] +} + +@test "variables do not persist across tests" { + [ -z "$variable" ] +}