Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Object reference not set to an instance of an object. #11

Open
harvinders opened this issue Oct 31, 2014 · 1 comment
Open

Object reference not set to an instance of an object. #11

harvinders opened this issue Oct 31, 2014 · 1 comment

Comments

@harvinders
Copy link

I setup my project just like in the example but keep on getting this exception.

I am using VS 2013, Win 8.1 64bit

System.NullReferenceException was unhandled by user code
  HResult=-2147467261
  Message=Object reference not set to an instance of an object.
  Source=TechTalk.SpecFlow
  StackTrace:
    Server stack trace: 
       at SpecFlow.Reporting.Reporters.ExecuteStep(Action action, MethodBase methodBase, Object[] args)
       at SpecFlow.Reporting.ReportingMessageSink.SyncProcessMessage(IMessage msg)
       at System.Runtime.Remoting.Lifetime.LeaseSink.SyncProcessMessage(IMessage msg)
       at System.Runtime.Remoting.Messaging.ServerContextTerminatorSink.SyncProcessMessage(IMessage reqMsg)
       at System.Runtime.Remoting.Channels.CrossContextChannel.SyncProcessMessageCallback(Object[] args)
       at System.Threading.Thread.CompleteCrossContextCallback(InternalCrossContextDelegate ftnToCall, Object[] args)
       at System.Threading.Thread.InternalCrossContextCallback(Context ctx, IntPtr ctxID, Int32 appDomainID, InternalCrossContextDelegate ftnToCall, Object[] args)
       at System.Runtime.Remoting.Channels.CrossContextChannel.SyncProcessMessage(IMessage reqMsg)
    Exception rethrown at [0]: 
       at System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage reqMsg, IMessage retMsg)
       at System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData& msgData, Int32 type)
       at Taf.Workflow.TestSpec.Steps.TestSpecificationSteps.GivenIHaveATestSpecificationTERev(String testspecificationId, String revision, String testing)
       at lambda_method(Closure , IContextManager , String , String , String )
       at TechTalk.SpecFlow.Bindings.BindingInvoker.InvokeBinding(IBinding binding, IContextManager contextManager, Object[] arguments, ITestTracer testTracer, TimeSpan& duration)
       at TechTalk.SpecFlow.Infrastructure.TestExecutionEngine.ExecuteStepMatch(BindingMatch match, Object[] arguments)
       at TechTalk.SpecFlow.Infrastructure.TestExecutionEngine.ExecuteStep(StepInstance stepInstance)
       at TechTalk.SpecFlow.Infrastructure.TestExecutionEngine.OnAfterLastStep()
       at TechTalk.SpecFlow.TestRunner.CollectScenarioErrors()
       at Taf.Example.Workflow.WorkflowFeature.ScenarioCleanup() in c:\Project\meccano\branch\tools\specbyexample\tests\Taf.Example.Workflow\Workflow.Simple.feature.cs:line 0
       at Taf.Example.Workflow.WorkflowFeature.SimpleTestSpecificationModification2() in c:\Project\meccano\branch\tools\specbyexample\tests\Taf.Example.Workflow\Workflow.Simple.feature:line 6
  InnerException: 
@italiangirl6
Copy link

In order to get SpecResults to work across the board, what I did was create a hook class that enherits > ReportingStepDefinitions

Create a static method with an attribute : BeforeTestRun
Inside the method you would choose which report structure you want (I use JSON):
Reporters.Add(new JsonReporter());

You will need to import >
using SpecResults;
using SpecResults.Json;

Then, create another static method within the hook class with either attributes:
AfterScenario/AfterFeature

For AfterScenario:
[AfterScenario]
public static void AfterScenarioRun() {
Reporters.FinishedScenario += (sender, args) => {
//Console.WriteLine(args.Reporter.WriteToString());
var serializedReport = JsonConvert.SerializeObject(args.Reporter);
//Console.Write(String.Format("{0}", JsonConvert.DeserializeObject(serializedReport)));
//Console.Write("\nEnd.");
};
}

For AfterFeature:
[AfterFeature]
public static void AfterFeatureRun()
{
Reporters.FinishedFeature += (sender, args) => {
//Console.WriteLine(args.Reporter.WriteToString());
var serializedReport = JsonConvert.SerializeObject(args.Reporter);
Console.Write(String.Format("{0}", JsonConvert.DeserializeObject(serializedReport)));
Console.Write("\nEnd.");
};
}

Notice the difference of Reporter.FinishedFeature & Reporter.FinishedScenario

Hope this helps.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants