I am trying to get the input parameter values for the function which I decorate with 'BeforeAfterTestAttribute', and I am not sure if this is really possible.
using System;
using System.Reflection;
using Custom.Foundation.Logger;
using Xunit.Sdk;
[AttributeUsage(AttributeTargets.Class | AttributeTargets.Method) ]
class ReportBeforeAttribute : BeforeAfterTestAttribute
{
private readonly string ExecutionTestCaseName;
public ReportBeforeAttribute(string testCaseName)
{
ExecutionTestCaseName = testCaseName;
}
public override void Before(MethodInfo methodUnderTest)
{
Trace.Log("Starting Method: " + ExecutionTestCaseName);
}
public override void After(MethodInfo methodUnderTest)
{
Trace.Log("MethodFinished ");
}
}
I want to pass the tc value from the method
[Theory]
[TestData("Execution")] //This Reads all Data Which will be run.
[ReportBefore("Execution")] //When decorating with this I want to read in the value tc, which the method will use.
public async Task CheckTest(TestCase tc)
{
//Some Code which is executed using TestCase tc.
}
Is this achievable, and if yes, how would that be possible?
public override void Before(MethodInfo methodUnderTest)
{
var testCase = //How to assign TestCase tc value here from the method being called?
Trace.Log("Starting Method: " + ExecutionTestCaseName);
}
Aucun commentaire:
Enregistrer un commentaire