-
Notifications
You must be signed in to change notification settings - Fork 64
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[NUnit] Fix async behaviour in [AllureStep] aspect + Allow '{obj.prop…
…}' placeholders in [AllureStep] step name (#329) Co-authored-by: Кабанов Константин Юрьевич <kykabano@mts.ru>
- Loading branch information
Showing
4 changed files
with
334 additions
and
105 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -265,3 +265,5 @@ __pycache__/ | |
.DS_Store | ||
*mono_crash* | ||
/.vscode | ||
|
||
.editorconfig |
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,67 @@ | ||
using System; | ||
using System.Reflection; | ||
using NUnit.Allure.Attributes; | ||
using NUnit.Allure.Core.Steps; | ||
using NUnit.Framework; | ||
|
||
namespace Allure.NUnit.Examples | ||
{ | ||
[AllureSuite("Tests - Step Names")] | ||
public class AllureStepNameInternalsTest : BaseTest | ||
{ | ||
internal class LocalTestClass | ||
{ | ||
public string TestField; | ||
public string TestProp { get; set; } | ||
|
||
public void TestMethod(string name, LocalTestClass request, int id) | ||
{ | ||
Console.WriteLine($"{id} - {name} ({request})"); | ||
} | ||
} | ||
|
||
[TestCase("", ExpectedResult = "")] | ||
[TestCase(null, ExpectedResult = "")] | ||
[TestCase("{0} - {1} - {2} - {3} - {100} - {-100}", ExpectedResult = "Super Mario - Allure.NUnit.Examples.AllureStepNameInternalsTest+LocalTestClass - 12345 - {3} - {100} - {-100}")] | ||
[TestCase("{id} - {0}", ExpectedResult = "12345 - Super Mario")] | ||
[TestCase("{id} - {name} ({request})", ExpectedResult = "12345 - Super Mario (Allure.NUnit.Examples.AllureStepNameInternalsTest+LocalTestClass)")] | ||
[TestCase("{id} - {request.TestField} - {request.TestProp}", ExpectedResult = "12345 - FieldValue - PropValue")] | ||
[TestCase("{notExistingParameter} - {request.NotExistingField}", ExpectedResult = "{notExistingParameter} - {request.NotExistingField}")] | ||
public string ApplyValues_Test(string stepNamePattern) | ||
{ | ||
MethodBase methodBase = typeof(LocalTestClass).GetMethod(nameof(LocalTestClass.TestMethod))!; | ||
object[] arguments = new object[] | ||
{ | ||
"Super Mario", // name = {0} | ||
new LocalTestClass // request = {1} | ||
{ | ||
TestField = "FieldValue", | ||
TestProp = "PropValue", | ||
}, | ||
12345, // id = {2} | ||
}; | ||
|
||
return AllureStepParameterHelper.GetStepName(stepNamePattern, methodBase, arguments); | ||
} | ||
|
||
[TestCase("", ExpectedResult = "")] | ||
[TestCase(null, ExpectedResult = "")] | ||
[TestCase("{0} - {1} - {2} - {3} - {100} - {-100}", ExpectedResult = "Super Mario - null - 12345 - {3} - {100} - {-100}")] | ||
[TestCase("{id} - {0}", ExpectedResult = "12345 - Super Mario")] | ||
[TestCase("{id} - {name} ({request})", ExpectedResult = "12345 - Super Mario (null)")] | ||
[TestCase("{id} - {request.TestField} - {request.TestProp}", ExpectedResult = "12345 - {request.TestField} - {request.TestProp}")] | ||
[TestCase("{notExistingParameter} - {request.NotExistingField}", ExpectedResult = "{notExistingParameter} - {request.NotExistingField}")] | ||
public string ApplyNullValues_Test(string stepNamePattern) | ||
{ | ||
MethodBase methodBase = typeof(LocalTestClass).GetMethod(nameof(LocalTestClass.TestMethod))!; | ||
object[] arguments = new object[] | ||
{ | ||
"Super Mario", // name = {0} | ||
null, | ||
12345, // id = {2} | ||
}; | ||
|
||
return AllureStepParameterHelper.GetStepName(stepNamePattern, methodBase, arguments); | ||
} | ||
} | ||
} |
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
Oops, something went wrong.