-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add SpecFlow BDD tests for blazor examples
Blazor: Allow multiple test assembles in the testbutton Blazor: Add SpecFlow test suites, enabling writing GUI tests in the Gherkin language.
- Loading branch information
1 parent
b44caa6
commit 5a2763e
Showing
53 changed files
with
1,451 additions
and
51 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
using System.Runtime.CompilerServices; | ||
|
||
[assembly: InternalsVisibleTo("asptest.blazor")] | ||
[assembly: InternalsVisibleTo("asptest.blazor.bunit")] | ||
[assembly: InternalsVisibleTo("asptest.blazor.bunit")] | ||
[assembly: InternalsVisibleTo("asptest.blazor.specflow")] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
using asp.blazor.Components.CalculatorParts; | ||
using static asptest.blazor.specflow.Features.CalculatorFeature; | ||
|
||
namespace asptest.blazor.specflow.Drivers | ||
{ | ||
public class CalculatorDriver | ||
{ | ||
public void EnterTheFirstNumber(int number) | ||
{ | ||
Driver.Navigate("/"); | ||
Driver.Click(Driver.Cut.footer.enterButton); | ||
Assert.That(Driver.State, Is.EqualTo(CalculatorContext.Map1.Enter)); | ||
Driver.Write(Driver.Dynamic<Enter>(Driver.Cut.calculatorPart).operand, number.ToString()); | ||
Driver.Click(Driver.Cut.footer.enterButton); | ||
Assert.That(Driver.State, Is.EqualTo(CalculatorContext.Map1.Calculate)); | ||
} | ||
|
||
public void EnterTheSecondNumber(int number) | ||
{ | ||
Driver.Click(Driver.Cut.footer.enterButton); | ||
Assert.That(Driver.State, Is.EqualTo(CalculatorContext.Map1.Enter)); | ||
Driver.Write(Driver.Dynamic<Enter>(Driver.Cut.calculatorPart).operand, number.ToString()); | ||
Driver.Click(Driver.Cut.footer.enterButton); | ||
Assert.That(Driver.State, Is.EqualTo(CalculatorContext.Map1.Calculate)); | ||
} | ||
|
||
public void ClickAdd() | ||
{ | ||
var before = Driver.Stack.Count; | ||
Driver.Click(Driver.Dynamic<Calculate>(Driver.Cut.calculatorPart).addButton); | ||
Assert.That(Driver.Stack.Count, Is.EqualTo(before - 1)); | ||
} | ||
|
||
public void ClickSub() | ||
{ | ||
var before = Driver.Stack.Count; | ||
Driver.Click(Driver.Dynamic<Calculate>(Driver.Cut.calculatorPart).subButton); | ||
Assert.That(Driver.Stack.Count, Is.EqualTo(before - 1)); | ||
} | ||
|
||
public void ClickMul() | ||
{ | ||
var before = Driver.Stack.Count; | ||
Driver.Click(Driver.Dynamic<Calculate>(Driver.Cut.calculatorPart).mulButton); | ||
Assert.That(Driver.Stack.Count, Is.EqualTo(before - 1)); | ||
} | ||
|
||
public void ClickDiv() | ||
{ | ||
var before = Driver.Stack.Count; | ||
Driver.Click(Driver.Dynamic<Calculate>(Driver.Cut.calculatorPart).divButton); | ||
Assert.That(Driver.Stack.Count, Is.EqualTo(before - 1)); | ||
} | ||
|
||
public void ClickPow() | ||
{ | ||
var before = Driver.Stack.Count; | ||
Driver.Click(Driver.Dynamic<Calculate>(Driver.Cut.calculatorPart).powButton); | ||
Assert.That(Driver.Stack.Count, Is.EqualTo(before)); | ||
} | ||
|
||
public void ClickSqrt() | ||
{ | ||
var before = Driver.Stack.Count; | ||
Driver.Click(Driver.Dynamic<Calculate>(Driver.Cut.calculatorPart).sqrtButton); | ||
Assert.That(Driver.Stack.Count, Is.EqualTo(before)); | ||
} | ||
|
||
public void AssertResultIs(int result) | ||
{ | ||
Assert.Multiple(() => | ||
{ | ||
Assert.That(Driver.State, Is.EqualTo(CalculatorContext.Map1.Calculate)); | ||
Assert.That(Driver.Stack.Peek(), Is.EqualTo(result.ToString())); | ||
Assert.That(Driver.Html(), Does.Contain(result.ToString())); | ||
}); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
using asp.blazor.CalculatorSmc; | ||
using asp.blazor.Components; | ||
using iselenium; | ||
using OpenQA.Selenium; | ||
|
||
namespace asptest.blazor.specflow.Drivers | ||
{ | ||
public abstract class CalculatorTestBase<TWebDriver> : | ||
SmcComponentDbTest<TWebDriver, CalculatorComponent, Calculator, CalculatorContext, CalculatorContext.CalculatorState> | ||
where TWebDriver : IWebDriver, new() | ||
{ | ||
public Stack<string> Stack | ||
{ | ||
get { return Main.Stack; } | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
Feature: Calculator | ||
|
||
SMC RPN calculator test assimilated to the SpecFlow template | ||
|
||
Scenario: Add two numbers | ||
Given the first number is 50 | ||
And the second number is 70 | ||
When the add button is clicked | ||
Then the result should be 120 | ||
|
||
Scenario: Subtract two numbers | ||
Given the first number is 70 | ||
And the second number is 50 | ||
When the subtract button is clicked | ||
Then the result should be 20 | ||
|
||
Scenario: Multiply two numbers | ||
Given the first number is 70 | ||
And the second number is 50 | ||
When the multiply button is clicked | ||
Then the result should be 3500 | ||
|
||
Scenario: Divide two numbers | ||
Given the first number is 70 | ||
And the second number is 5 | ||
When the divide button is clicked | ||
Then the result should be 14 | ||
|
||
Scenario: Square a number | ||
Given the first number is 70 | ||
When the square button is clicked | ||
Then the result should be 4900 | ||
|
||
Scenario: Extract the root from a number | ||
Given the first number is 49 | ||
When the square root button is clicked | ||
Then the result should be 7 |
Oops, something went wrong.