diff --git a/.github/FUNDING.yml b/.github/FUNDING.yml
new file mode 100644
index 0000000..9a819b1
--- /dev/null
+++ b/.github/FUNDING.yml
@@ -0,0 +1,15 @@
+# These are supported funding model platforms
+
+github: [yanjustino]
+patreon: # Replace with a single Patreon username
+open_collective: # Replace with a single Open Collective username
+ko_fi: # Replace with a single Ko-fi username
+tidelift: # Replace with a single Tidelift platform-name/package-name e.g., npm/babel
+community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry
+liberapay: # Replace with a single Liberapay username
+issuehunt: # Replace with a single IssueHunt username
+lfx_crowdfunding: # Replace with a single LFX Crowdfunding project-name e.g., cloud-foundry
+polar: # Replace with a single Polar username
+buy_me_a_coffee: # Replace with a single Buy Me a Coffee username
+thanks_dev: # Replace with a single thanks.dev username
+custom: # Replace with up to 4 custom sponsorship URLs e.g., ['link1', 'link2']
diff --git a/README.md b/README.md
index 8d72e6d..d5fe40e 100644
--- a/README.md
+++ b/README.md
@@ -97,44 +97,41 @@ TEST RESULT: 🟢 SUCCESS
| THEN ↘ she sees a Free article and a Paid article
```
-### ✏️ Customizing the lexical elements of Gherkin
+### 🔎 Is GherXunit for You?
+If your team already uses xUnit and wants to experiment with a BDD approach without drastically changing its workflow, **GherXunit** may be an option to consider. It does not eliminate all BDD challenges but seeks to facilitate its adoption in environments where xUnit is already widely used.
+See more usage examples and implementation details for `Background`, `Rule`, `Features`, and other elements in the [sample code](/src/base/GherXunit.Core/Samples) available in the **GherXunit** repository.
-The **GherXunit** allows you to customize the lexical elements of Gherkin, such as `Given`, `When`, `Then`, `And`, `Background`, `Scenario`, and `Feature`.
-You can define your custom emojis or symbols to represent these elements. The following code snippet shows an example of a custom lexer for emojis:
-```csharp
-// Custom lexer for emojis
-public record EmojiGherXunitLexer : IGherXunitLexer
-{
- public (string Key, string Value)[] Given => [("Given", "\ud83d\ude10")];
- public (string Key, string Value)[] When => [("When", "\ud83c\udfac")];
- public (string Key, string Value)[] Then => [("Then", "\ud83d\ude4f")];
- public (string Key, string Value)[] And => [("And", "\ud83d\ude02")];
- public string Background => "\ud83d\udca4";
- public string Scenario => "\ud83e\udd52\ud83d\udcd5";
- public string Feature => "\ud83d\udcda";
-}
-```
-The Gherkin provides two built-in lexers: `Lexers.PtBr` for Portuguese (🇵🇹🇧🇷) and `Lexers.EnUs` for English (🇺🇸).
-You can also create your custom lexer by implementing the `IGherXunitLexer` interface. To use the custom lexer,
-you need to pass it as a parameter when defining the test scenario.
+
+## 📚 References
+
+- 📖 **Farooq, M. S., et al. (2023). Behavior Driven Development**: *A Systematic Literature Review. IEEE* Access. DOI: [10.1109/ACCESS.2023.3302356](https://doi.org/10.1109/ACCESS.2023.3302356).
+- 📖 **North, D. (2006)**. *Introducing BDD. DanNorth.net.* Available at: [https://dannorth.net/introducing-bdd/](https://dannorth.net/introducing-bdd/).
+- 📖 **xUnit. (2023)**. *xUnit.net.* Available at: [https://xunit.net/](https://xunit.net/).
+- 📖 **Gherkin. (2023)**. *Gherkin.* Available at: [https://cucumber.io/docs/gherkin/](https://cucumber.io/docs/gherkin/).
+
+### 📌 Definindo o Lexer globalmente
+
+A partir da versão 1.3.0, você pode definir o Lexer padrão para todos os testes do projeto (ou de uma classe) usando `GherXunitConfig.DefaultLexer`:
```csharp
-[Feature("Subscribers see different articles based on their subscription level")]
public partial class LocalizationTest
{
- // Using Portuguese (🇵🇹🇧🇷) lexer
+ static LocalizationTest()
+ {
+ GherXunitConfig.DefaultLexer = Lexers.PtBr; // Define o padrão para todos os testes desta classe
+ }
+
[Scenario("Inscrever-se para ver artigos gratuitos")]
async Task WhenFriedaLogs() => await this.ExecuteAscync(
refer: WhenFriedaLogsSteps,
- lexer: Lexers.PtBr,
steps: """
Dado Free Frieda possui uma assinatura gratuita
Quando Free Frieda faz login com suas credenciais válidas
Então ela vê um artigo gratuito
""");
- // Using custom emoji lexer
- [Scenario("Subscriber with a paid subscription can access both free and paid articles")]
+ // Para cenários que precisam de um lexer diferente, basta passar o parâmetro normalmente:
+ [Scenario("Custom emoji lexer")]
void WhenPattyLogs() => this.Execute(
refer: WhenPattyLogsSteps,
lexer: new EmojiGherXunitLexer(),
@@ -145,31 +142,5 @@ public partial class LocalizationTest
""");
}
```
-The result of running the test scenarios defined in the `LocalizationTest` class using the custom lexer would be similar to the following output:
-```gherkindotnet
-TEST RESULT: 🟢 SUCCESS
-⤷ FUNCIONALIDADE Subscribers see different articles based on their subscription level
- ⤷ CENARIO Inscrever-se para ver artigos gratuitos
- | DADO ↘ Free Frieda possui uma assinatura gratuita
- | QUANDO ↘ Free Frieda faz login com suas credenciais válidas
- | ENTÃO ↘ ela vê um artigo gratuito
-
-TEST RESULT: 🟢 SUCCESS
-⤷ 📚 Subscribers see different articles based on their subscription level
- ⤷ 🥒📕 Subscriber with a paid subscription can access both free and paid articles
- | 😐 ↘ Paid Patty has a basic-level paid subscription
- | 🎬 ↘ Paid Patty logs in with her valid credentials
- | 🙏 ↘ she sees a Free article and a Paid article
-```
-### 🔎 Is GherXunit for You?
-If your team already uses xUnit and wants to experiment with a BDD approach without drastically changing its workflow, **GherXunit** may be an option to consider. It does not eliminate all BDD challenges but seeks to facilitate its adoption in environments where xUnit is already widely used.
-See more usage examples and implementation details for `Background`, `Rule`, `Features`, and other elements in the [sample code](/src/base/GherXunit.Core/Samples) available in the **GherXunit** repository.
-
-
-## 📚 References
-
-- 📖 **Farooq, M. S., et al. (2023). Behavior Driven Development**: *A Systematic Literature Review. IEEE* Access. DOI: [10.1109/ACCESS.2023.3302356](https://doi.org/10.1109/ACCESS.2023.3302356).
-- 📖 **North, D. (2006)**. *Introducing BDD. DanNorth.net.* Available at: [https://dannorth.net/introducing-bdd/](https://dannorth.net/introducing-bdd/).
-- 📖 **xUnit. (2023)**. *xUnit.net.* Available at: [https://xunit.net/](https://xunit.net/).
-- 📖 **Gherkin. (2023)**. *Gherkin.* Available at: [https://cucumber.io/docs/gherkin/](https://cucumber.io/docs/gherkin/).
+> **Dica:** O parâmetro `lexer` só precisa ser informado no teste se você quiser sobrescrever o padrão global.
diff --git a/src/base/GherXunit.Core/Methods.cs b/src/base/GherXunit.Core/Methods.cs
index c3e2cf8..fdf3200 100644
--- a/src/base/GherXunit.Core/Methods.cs
+++ b/src/base/GherXunit.Core/Methods.cs
@@ -64,7 +64,7 @@ private static void Write(this IGherXunitStep scenario, string? methodName, stri
? $"{(isBackground ? "Background" : "Scenario")} {methodName}\r\n"
: $"{(isBackground ? "Background" : "Scenario")} {iTest.DisplayName}\r\n";
- var stepString = new StringHandler(lexer ?? Lexers.EnUs);
+ var stepString = new StringHandler(lexer ?? GherXunitConfig.DefaultLexer ?? Lexers.EnUs);
stepString.AppendLiteral($"{statusResult}{featuresText}{scenarioText}{steps}");
output?.WriteLine(".");
diff --git a/src/base/GherXunit.Core/Samples/Localization/LocalizationTest.cs b/src/base/GherXunit.Core/Samples/Localization/LocalizationTest.cs
index 9863c04..c1e8c25 100644
--- a/src/base/GherXunit.Core/Samples/Localization/LocalizationTest.cs
+++ b/src/base/GherXunit.Core/Samples/Localization/LocalizationTest.cs
@@ -5,10 +5,14 @@ namespace BddTests.Samples.Localization;
[Feature("Subscribers see different articles based on their subscription level")]
public partial class LocalizationTest
{
+ static LocalizationTest()
+ {
+ GherXunitConfig.DefaultLexer = Lexers.PtBr;
+ }
+
[Scenario("Inscrever-se para ver artigos gratuitos")]
async Task WhenFriedaLogs() => await this.ExecuteAscync(
refer: WhenFriedaLogsSteps,
- lexer: Lexers.PtBr,
steps: """
Dado Free Frieda possui uma assinatura gratuita
Quando Free Frieda faz login com suas credenciais válidas
diff --git a/src/base/GherXunit.Core/StringHandler.cs b/src/base/GherXunit.Core/StringHandler.cs
index 44986bb..6a74f78 100644
--- a/src/base/GherXunit.Core/StringHandler.cs
+++ b/src/base/GherXunit.Core/StringHandler.cs
@@ -62,4 +62,9 @@ public record PtBrGherXunitLexer : IGherXunitLexer
public string Background => "CONTEXTO";
public string Scenario => "CENARIO";
public string Feature => "FUNCIONALIDADE";
+}
+
+public static class GherXunitConfig
+{
+ public static IGherXunitLexer? DefaultLexer { get; set; }
}
\ No newline at end of file
diff --git a/src/lib/GherXunit/GherXunit.Content.Methods.cs b/src/lib/GherXunit/GherXunit.Content.Methods.cs
index bce9838..510dcf4 100644
--- a/src/lib/GherXunit/GherXunit.Content.Methods.cs
+++ b/src/lib/GherXunit/GherXunit.Content.Methods.cs
@@ -74,7 +74,7 @@ private static void Write(this IGherXunitStep scenario, string? methodName, stri
? $"{(isBackground ? "Background" : "Scenario")} {methodName}\r\n"
: $"{(isBackground ? "Background" : "Scenario")} {iTest.DisplayName}\r\n";
- var stepString = new StringHandler(lexer ?? Lexers.Default);
+ var stepString = new StringHandler(lexer ?? GherXunitConfig.DefaultLexer ?? Lexers.Default);
stepString.AppendLiteral($"{statusResult}{featuresText}{scenarioText}{steps}");
output?.WriteLine(".");
diff --git a/src/lib/GherXunit/GherXunit.Content.StringHandler.cs b/src/lib/GherXunit/GherXunit.Content.StringHandler.cs
index f352cf1..2a13af1 100644
--- a/src/lib/GherXunit/GherXunit.Content.StringHandler.cs
+++ b/src/lib/GherXunit/GherXunit.Content.StringHandler.cs
@@ -69,5 +69,10 @@ public record PtBrGherXunitLexer : IGherXunitLexer
public string Scenario => "CENARIO";
public string Feature => "FUNCIONALIDADE";
}
+
+ public static class GherXunitConfig
+ {
+ public static IGherXunitLexer? DefaultLexer { get; set; }
+ }
""";
}
\ No newline at end of file
diff --git a/src/lib/GherXunit/GherXunit.csproj b/src/lib/GherXunit/GherXunit.csproj
index 21da8b5..9b1f3e1 100644
--- a/src/lib/GherXunit/GherXunit.csproj
+++ b/src/lib/GherXunit/GherXunit.csproj
@@ -7,7 +7,7 @@
true
true
GherXunit
- 1.2.0
+ 1.3.0
Yan Justino
Emergingcode
GherXunit emerges as a viable alternative for those seeking an approach that combines the expressiveness of BDD with the well-established structure of xUnit.