Skip to content

Commit

Permalink
added tests
Browse files Browse the repository at this point in the history
  • Loading branch information
kiranparajuli589 committed Apr 15, 2021
1 parent 36b2388 commit 53ca275
Show file tree
Hide file tree
Showing 4 changed files with 77 additions and 1 deletion.
2 changes: 1 addition & 1 deletion scan.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ func scanForNewScenarios() {
}
}
if !found {
fmt.Println("new scenario found")
fmt.Println("found new scenario")
fmt.Println("New: ", getTestPath(l))
fmt.Println("")
}
Expand Down
5 changes: 5 additions & 0 deletions tests/fixtures/expectedFailure1.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
### Superheros are not immortal
- [superHeroes/hero.feature: 11](https://github.com/JankariTech/expected-failures-updater/blob/master/tests/fixtures/features/superHeroes/hero.feature#L11)
- [superHeroes/hero.feature: 15](https://github.com/JankariTech/expected-failures-updater/blob/master/tests/fixtures/features/superHeroes/hero.feature#L15)
- [superHeroes/hero.feature: 24](https://github.com/JankariTech/expected-failures-updater/blob/master/tests/fixtures/features/superHeroes/hero.feature#L24)
- [superHeroes/hero.feature: 25](https://github.com/JankariTech/expected-failures-updater/blob/master/tests/fixtures/features/superHeroes/hero.feature#L25)
29 changes: 29 additions & 0 deletions tests/fixtures/features/superHeroes/hero.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
Feature: hero feature
As a hero
I want to be able fight so hard
So that I can save my city from danger

Background:
Given laboratory has summoned a local super hero

Scenario: color of the cloak
When the superhero flies on the sky
Then color of its cloak should be "golden"

Scenario: saviour of the city
When the superhero is online
Then citizens should be safe

Scenario Outline: superheros and their cloaks
Given laboratory has summoned "<super-hero>"
When the hero files on the sky
Then the color of its cloak should be "<color>"
Examples:
| super-hero | color |
| Thor | dark |
| Iron Man | purple |
| Hulk | green |

Scenario: party wizard
When the superhero and party wizard are together
Then the city should be filled with parties
42 changes: 42 additions & 0 deletions tests/test_scan_command.bats
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
#!/usr/bin/env bash
# echo "# ""${lines[0]}" >&3

function setup() {
# save hero feature content for future tests
mkdir tests/tmp
cp tests/fixtures/features/superHeroes/hero.feature tests/tmp/hero.feature

# cache the existing feature
export FEATURES_PATH=tests/fixtures/features
make cache
}


@test "detect removed scenarios" {
# remove a scenario from the cached feature
sed -i '27,29d' tests/fixtures/features/superHeroes/hero.feature

# scan the cached feature directory
run make scan
[ "$status" -eq 0 ]
[ "${lines[1]}" = "scenario got removed" ]
[ "${lines[2]}" = "Deleted: superHeroes/hero.feature:27" ]
}

@test "detect new added scenarios" {
# add a new scenario into the cached feature
echo -e "\n Scenario: new scene\n When this\n Then that\n" >> tests/fixtures/features/superHeroes/hero.feature

# scan the cached feature directory
run make scan

[ "$status" -eq 0 ]
[ "${lines[1]}" = "found new scenario" ]
[ "${lines[2]}" = "New: superHeroes/hero.feature:31" ]
}

function teardown() {
# revert the modified feature file
mv tests/tmp/hero.feature tests/fixtures/features/superHeroes/hero.feature
rm -rf tests/tmp
}

0 comments on commit 53ca275

Please sign in to comment.