getgauge / gauge-visualstudio

Visual Studio plugin for Gauge
10 stars 9 forks source link

SerializationException: There was an error deserializing the object of type Gauge.VisualStudio.TestAdapter.TestExecutionEvent. Encountered invalid character ' '. #253

Closed ssg47 closed 5 years ago

ssg47 commented 5 years ago

Expected behavior

No exceptions should be generated by the plugin after a successful build on value spec and step implementation files.

Actual behavior

System.Runtime.Serialization.SerializationException: There was an error deserializing the object of type Gauge.VisualStudio.TestAdapter.TestExecutionEvent. Encountered invalid character ' '. ---> System.FormatException: Encountered invalid character ' '. at [...]

Steps to reproduce

To recreate:

  1. Create a new Gauge project.

  2. Build the project (to trigger NuGet restore).

  3. Open the StepImplementation.

  4. Open the example.spec and use New Vertical Tab Group, so you can see both files.

  5. In Test Explorer, click Run All.

  6. See

    ------ Discover test started ------
    Discover Scenarios started. Using : ProjectRoot: D:\Source\GaugeProject5\GaugeProject5, OutputPath: D:\Source\GaugeProject5\GaugeProject5\bin\Debug\, API Port: 46343
    Adding test cases from : D:\Source\GaugeProject5\GaugeProject5\specs\example.spec
    Discovered scenario: Vowel counts in single word
    Discovered scenario: Vowel counts in multiple word
    ========== Discover test finished: 2 found (0:00:00.1559297) ==========
    ------ Run test started ------
    Discover Scenarios started. Using : ProjectRoot: D:\Source\GaugeProject5\GaugeProject5, OutputPath: D:\Source\GaugeProject5\GaugeProject5\bin\Debug\, API Port: 46343
    Adding test cases from : D:\Source\GaugeProject5\GaugeProject5\specs\example.spec
    Discovered scenario: Vowel counts in single word
    Discovered scenario: Vowel counts in multiple word
    Executing Test: Vowel counts in single word
    Executing Test: Vowel counts in multiple word
    Invoking : gauge.exe - Arguments:run "D:\Source\GaugeProject5\GaugeProject5\specs\example.spec:14" "D:\Source\GaugeProject5\GaugeProject5\specs\example.spec:22" --machine-readable; ENV -  [redacted]
    No test is available in D:\Source\GaugeProject5\GaugeProject5\specs\example.spec. Make sure that installed test discoverers & executors, platform & framework version settings are appropriate and try again.
    ========== Run test finished: 0 run (0:00:34.0609178) ==========
  7. Edit * The word "gauge" has "3" vowels. to read * The word "gauge" has "4" vowels.. In a different recreating-the-problem project, this caused it to lose all of the tests and test explorer was empty. In this case, it didn't work. (One of the difficulties in reporting cases is that I don't get the same experience every time.)

  8. Build the solution:

    1>------ Build started: Project: GaugeProject5, Configuration: Debug Any CPU ------
    1>  GaugeProject5 -> D:\Source\GaugeProject5\GaugeProject5\bin\Debug\GaugeProject5.dll
    ========== Build: 1 succeeded, 0 failed, 0 up-to-date, 0 skipped ==========
  9. I edited the above line back to 3, rebuilt and still couldn't recreate it (missing tests issue). I think at this point, I closed the project and re-opened GaugeProject4 where I had the missing tests. Then closed and reopened this project. I think I hit Build and it found all of the tests and then this appeared:

    ------ Discover test started ------
    Discover Scenarios started. Using : ProjectRoot: D:\Source\GaugeProject5\GaugeProject5, OutputPath: D:\Source\GaugeProject5\GaugeProject5\bin\Debug\, API Port: 46346
    Adding test cases from : D:\Source\GaugeProject5\GaugeProject5\specs\example.spec
    Discovered scenario: Vowel counts in single word
    Discovered scenario: Vowel counts in multiple word
    ========== Discover test finished: 2 found (0:00:00.1330083) ==========
    ------ Run test started ------
    Discover Scenarios started. Using : ProjectRoot: D:\Source\GaugeProject5\GaugeProject5, OutputPath: D:\Source\GaugeProject5\GaugeProject5\bin\Debug\, API Port: 46346
    Adding test cases from : D:\Source\GaugeProject5\GaugeProject5\specs\example.spec
    Discovered scenario: Vowel counts in single word
    Discovered scenario: Vowel counts in multiple word
    Executing Test: Vowel counts in single word
    Executing Test: Vowel counts in multiple word
    Invoking : gauge.exe - Arguments:run "D:\Source\GaugeProject5\GaugeProject5\specs\example.spec:14" "D:\Source\GaugeProject5\GaugeProject5\specs\example.spec:22" --machine-readable; ENV -  [redacted]
    System.Runtime.Serialization.SerializationException: There was an error deserializing the object of type Gauge.VisualStudio.TestAdapter.TestExecutionEvent. Encountered invalid character ' '. ---> System.FormatException: Encountered invalid character ' '.
    at System.Runtime.Serialization.Json.XmlJsonReader.ComputeQuotedTextLengthUntilEndQuote(Byte[] buffer, Int32 offset, Int32 offsetMax, Boolean& escaped)
    at System.Runtime.Serialization.Json.XmlJsonReader.ReadQuotedText(Boolean moveToText)
    at System.Runtime.Serialization.Json.XmlJsonReader.Read()
    at System.Xml.XmlBaseReader.Skip()
    at System.Runtime.Serialization.XmlObjectSerializerReadContext.SkipUnknownElement(XmlReaderDelegator xmlReader)
    at System.Runtime.Serialization.XmlObjectSerializerReadContext.HandleMemberNotFound(XmlReaderDelegator xmlReader, ExtensionDataObject extensionData, Int32 memberIndex)
    at System.Runtime.Serialization.Json.XmlObjectSerializerReadContextComplexJson.GetJsonMemberIndex(XmlReaderDelegator xmlReader, XmlDictionaryString[] memberNames, Int32 memberIndex, ExtensionDataObject extensionData)
    at ReadTestExecutionEventFromJson(XmlReaderDelegator , XmlObjectSerializerReadContextComplexJson , XmlDictionaryString , XmlDictionaryString[] )
    at System.Runtime.Serialization.Json.JsonClassDataContract.ReadJsonValueCore(XmlReaderDelegator jsonReader, XmlObjectSerializerReadContextComplexJson context)
    at System.Runtime.Serialization.Json.JsonDataContract.ReadJsonValue(XmlReaderDelegator jsonReader, XmlObjectSerializerReadContextComplexJson context)
    at System.Runtime.Serialization.Json.XmlObjectSerializerReadContextComplexJson.ReadDataContractValue(DataContract dataContract, XmlReaderDelegator reader)
    at System.Runtime.Serialization.XmlObjectSerializerReadContext.InternalDeserialize(XmlReaderDelegator reader, String name, String ns, Type declaredType, DataContract& dataContract)
    at System.Runtime.Serialization.XmlObjectSerializerReadContextComplex.InternalDeserialize(XmlReaderDelegator xmlReader, Type declaredType, DataContract dataContract, String name, String ns)
    at System.Runtime.Serialization.Json.DataContractJsonSerializer.InternalReadObject(XmlReaderDelegator xmlReader, Boolean verifyObjectName)
    at System.Runtime.Serialization.XmlObjectSerializer.InternalReadObject(XmlReaderDelegator reader, Boolean verifyObjectName, DataContractResolver dataContractResolver)
    at System.Runtime.Serialization.XmlObjectSerializer.ReadObjectHandleExceptions(XmlReaderDelegator reader, Boolean verifyObjectName, DataContractResolver dataContractResolver)
    --- End of inner exception stack trace ---
    at System.Runtime.Serialization.XmlObjectSerializer.ReadObjectHandleExceptions(XmlReaderDelegator reader, Boolean verifyObjectName, DataContractResolver dataContractResolver)
    at System.Runtime.Serialization.Json.DataContractJsonSerializer.ReadObject(XmlDictionaryReader reader)
    at System.Runtime.Serialization.Json.DataContractJsonSerializer.ReadObject(Stream stream)
    at Gauge.VisualStudio.TestAdapter.GaugeRunner.OnOutputDataReceived(Object sender, DataReceivedEventArgs args)
    at System.Diagnostics.Process.OutputReadNotifyUser(String data)
    at System.Diagnostics.AsyncStreamReader.FlushMessageQueue()
    at System.Diagnostics.AsyncStreamReader.GetLinesFromStringBuilder()
    at System.Diagnostics.AsyncStreamReader.ReadBuffer(IAsyncResult ar)
    at System.IO.Stream.ReadWriteTask.InvokeAsyncCallback(Object completedTask)
    at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
    at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
    at System.IO.Stream.ReadWriteTask.System.Threading.Tasks.ITaskCompletionAction.Invoke(Task completingTask)
    at System.Threading.Tasks.Task.FinishContinuations()
    at System.Threading.Tasks.Task.FinishStageThree()
    at System.Threading.Tasks.Task.FinishStageTwo()
    at System.Threading.Tasks.Task.Finish(Boolean bUserDelegateExecuted)
    at System.Threading.Tasks.Task.ExecuteWithThreadLocal(Task& currentTaskSlot)
    at System.Threading.Tasks.Task.ExecuteEntry(Boolean bPreventDoubleExecution)
    at System.Threading.Tasks.Task.System.Threading.IThreadPoolWorkItem.ExecuteWorkItem()
    at System.Threading.ThreadPoolWorkQueue.Dispatch()
    at System.Threading._ThreadPoolWaitCallback.PerformWaitCallback()
    Encountered invalid character ' '.
    at System.Runtime.Serialization.XmlObjectSerializer.ReadObjectHandleExceptions(XmlReaderDelegator reader, Boolean verifyObjectName, DataContractResolver dataContractResolver)
    at System.Runtime.Serialization.Json.DataContractJsonSerializer.ReadObject(XmlDictionaryReader reader)
    at System.Runtime.Serialization.Json.DataContractJsonSerializer.ReadObject(Stream stream)
    at Gauge.VisualStudio.TestAdapter.GaugeRunner.OnOutputDataReceived(Object sender, DataReceivedEventArgs args)
    at System.Diagnostics.Process.OutputReadNotifyUser(String data)
    at System.Diagnostics.AsyncStreamReader.FlushMessageQueue()
    at System.Diagnostics.AsyncStreamReader.GetLinesFromStringBuilder()
    at System.Diagnostics.AsyncStreamReader.ReadBuffer(IAsyncResult ar)
    at System.IO.Stream.ReadWriteTask.InvokeAsyncCallback(Object completedTask)
    at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
    at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
    at System.IO.Stream.ReadWriteTask.System.Threading.Tasks.ITaskCompletionAction.Invoke(Task completingTask)
    at System.Threading.Tasks.Task.FinishContinuations()
    at System.Threading.Tasks.Task.FinishStageThree()
    at System.Threading.Tasks.Task.FinishStageTwo()
    at System.Threading.Tasks.Task.Finish(Boolean bUserDelegateExecuted)
    at System.Threading.Tasks.Task.ExecuteWithThreadLocal(Task& currentTaskSlot)
    at System.Threading.Tasks.Task.ExecuteEntry(Boolean bPreventDoubleExecution)
    at System.Threading.Tasks.Task.System.Threading.IThreadPoolWorkItem.ExecuteWorkItem()
    at System.Threading.ThreadPoolWorkQueue.Dispatch()
    at System.Threading._ThreadPoolWaitCallback.PerformWaitCallback()
    No test is available in D:\Source\GaugeProject5\GaugeProject5\specs\example.spec. Make sure that installed test discoverers & executors, platform & framework version settings are appropriate and try again.
    ========== Run test finished: 0 run (0:00:30.4298283) ==========

    Tests are greyed-out after this: image

  10. I ran Clean Solution, then Build Solution. The tests were still greyed-out but I click Run All and they ran successfully, went green in Test Explorer. By the time I'd finished typing the above sentence they'd greyed-out again and the same (?) error message had appeared:

    ------ Discover test started ------
    Discover Scenarios started. Using : ProjectRoot: D:\Source\GaugeProject5\GaugeProject5, OutputPath: D:\Source\GaugeProject5\GaugeProject5\bin\Debug\, API Port: 46346
    Adding test cases from : D:\Source\GaugeProject5\GaugeProject5\specs\example.spec
    Discovered scenario: Vowel counts in single word
    Discovered scenario: Vowel counts in multiple word
    ========== Discover test finished: 2 found (0:00:00.1230029) ==========
    ------ Run test started ------
    Discover Scenarios started. Using : ProjectRoot: D:\Source\GaugeProject5\GaugeProject5, OutputPath: D:\Source\GaugeProject5\GaugeProject5\bin\Debug\, API Port: 46346
    Adding test cases from : D:\Source\GaugeProject5\GaugeProject5\specs\example.spec
    Discovered scenario: Vowel counts in single word
    Discovered scenario: Vowel counts in multiple word
    Executing Test: Vowel counts in single word
    Executing Test: Vowel counts in multiple word
    Invoking : gauge.exe - Arguments:run "D:\Source\GaugeProject5\GaugeProject5\specs\example.spec:14" "D:\Source\GaugeProject5\GaugeProject5\specs\example.spec:22" --machine-readable; ENV - 
    [removed]
    System.Runtime.Serialization.SerializationException: There was an error deserializing the object of type Gauge.VisualStudio.TestAdapter.TestExecutionEvent. Encountered invalid character ' '. ---> System.FormatException: Encountered invalid character ' '.
    at System.Runtime.Serialization.Json.XmlJsonReader.ComputeQuotedTextLengthUntilEndQuote(Byte[] buffer, Int32 offset, Int32 offsetMax, Boolean& escaped)
    at System.Runtime.Serialization.Json.XmlJsonReader.ReadQuotedText(Boolean moveToText)
    at System.Runtime.Serialization.Json.XmlJsonReader.Read()
    at System.Xml.XmlBaseReader.Skip()
    at System.Runtime.Serialization.XmlObjectSerializerReadContext.SkipUnknownElement(XmlReaderDelegator xmlReader)
    at System.Runtime.Serialization.XmlObjectSerializerReadContext.HandleMemberNotFound(XmlReaderDelegator xmlReader, ExtensionDataObject extensionData, Int32 memberIndex)
    at System.Runtime.Serialization.Json.XmlObjectSerializerReadContextComplexJson.GetJsonMemberIndex(XmlReaderDelegator xmlReader, XmlDictionaryString[] memberNames, Int32 memberIndex, ExtensionDataObject extensionData)
    at ReadTestExecutionEventFromJson(XmlReaderDelegator , XmlObjectSerializerReadContextComplexJson , XmlDictionaryString , XmlDictionaryString[] )
    at System.Runtime.Serialization.Json.JsonClassDataContract.ReadJsonValueCore(XmlReaderDelegator jsonReader, XmlObjectSerializerReadContextComplexJson context)
    at System.Runtime.Serialization.Json.JsonDataContract.ReadJsonValue(XmlReaderDelegator jsonReader, XmlObjectSerializerReadContextComplexJson context)
    at System.Runtime.Serialization.Json.XmlObjectSerializerReadContextComplexJson.ReadDataContractValue(DataContract dataContract, XmlReaderDelegator reader)
    at System.Runtime.Serialization.XmlObjectSerializerReadContext.InternalDeserialize(XmlReaderDelegator reader, String name, String ns, Type declaredType, DataContract& dataContract)
    at System.Runtime.Serialization.XmlObjectSerializerReadContextComplex.InternalDeserialize(XmlReaderDelegator xmlReader, Type declaredType, DataContract dataContract, String name, String ns)
    at System.Runtime.Serialization.Json.DataContractJsonSerializer.InternalReadObject(XmlReaderDelegator xmlReader, Boolean verifyObjectName)
    at System.Runtime.Serialization.XmlObjectSerializer.InternalReadObject(XmlReaderDelegator reader, Boolean verifyObjectName, DataContractResolver dataContractResolver)
    at System.Runtime.Serialization.XmlObjectSerializer.ReadObjectHandleExceptions(XmlReaderDelegator reader, Boolean verifyObjectName, DataContractResolver dataContractResolver)
    --- End of inner exception stack trace ---
    at System.Runtime.Serialization.XmlObjectSerializer.ReadObjectHandleExceptions(XmlReaderDelegator reader, Boolean verifyObjectName, DataContractResolver dataContractResolver)
    at System.Runtime.Serialization.Json.DataContractJsonSerializer.ReadObject(XmlDictionaryReader reader)
    at System.Runtime.Serialization.Json.DataContractJsonSerializer.ReadObject(Stream stream)
    at Gauge.VisualStudio.TestAdapter.GaugeRunner.OnOutputDataReceived(Object sender, DataReceivedEventArgs args)
    at System.Diagnostics.Process.OutputReadNotifyUser(String data)
    at System.Diagnostics.AsyncStreamReader.FlushMessageQueue()
    at System.Diagnostics.AsyncStreamReader.GetLinesFromStringBuilder()
    at System.Diagnostics.AsyncStreamReader.ReadBuffer(IAsyncResult ar)
    at System.IO.Stream.ReadWriteTask.InvokeAsyncCallback(Object completedTask)
    at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
    at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
    at System.IO.Stream.ReadWriteTask.System.Threading.Tasks.ITaskCompletionAction.Invoke(Task completingTask)
    at System.Threading.Tasks.Task.FinishContinuations()
    at System.Threading.Tasks.Task.FinishStageThree()
    at System.Threading.Tasks.Task.FinishStageTwo()
    at System.Threading.Tasks.Task.Finish(Boolean bUserDelegateExecuted)
    at System.Threading.Tasks.Task.ExecuteWithThreadLocal(Task& currentTaskSlot)
    at System.Threading.Tasks.Task.ExecuteEntry(Boolean bPreventDoubleExecution)
    at System.Threading.Tasks.Task.System.Threading.IThreadPoolWorkItem.ExecuteWorkItem()
    at System.Threading.ThreadPoolWorkQueue.Dispatch()
    at System.Threading._ThreadPoolWaitCallback.PerformWaitCallback()
    Encountered invalid character ' '.
    at System.Runtime.Serialization.XmlObjectSerializer.ReadObjectHandleExceptions(XmlReaderDelegator reader, Boolean verifyObjectName, DataContractResolver dataContractResolver)
    at System.Runtime.Serialization.Json.DataContractJsonSerializer.ReadObject(XmlDictionaryReader reader)
    at System.Runtime.Serialization.Json.DataContractJsonSerializer.ReadObject(Stream stream)
    at Gauge.VisualStudio.TestAdapter.GaugeRunner.OnOutputDataReceived(Object sender, DataReceivedEventArgs args)
    at System.Diagnostics.Process.OutputReadNotifyUser(String data)
    at System.Diagnostics.AsyncStreamReader.FlushMessageQueue()
    at System.Diagnostics.AsyncStreamReader.GetLinesFromStringBuilder()
    at System.Diagnostics.AsyncStreamReader.ReadBuffer(IAsyncResult ar)
    at System.IO.Stream.ReadWriteTask.InvokeAsyncCallback(Object completedTask)
    at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
    at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
    at System.IO.Stream.ReadWriteTask.System.Threading.Tasks.ITaskCompletionAction.Invoke(Task completingTask)
    at System.Threading.Tasks.Task.FinishContinuations()
    at System.Threading.Tasks.Task.FinishStageThree()
    at System.Threading.Tasks.Task.FinishStageTwo()
    at System.Threading.Tasks.Task.Finish(Boolean bUserDelegateExecuted)
    at System.Threading.Tasks.Task.ExecuteWithThreadLocal(Task& currentTaskSlot)
    at System.Threading.Tasks.Task.ExecuteEntry(Boolean bPreventDoubleExecution)
    at System.Threading.Tasks.Task.System.Threading.IThreadPoolWorkItem.ExecuteWorkItem()
    at System.Threading.ThreadPoolWorkQueue.Dispatch()
    at System.Threading._ThreadPoolWaitCallback.PerformWaitCallback()
    No test is available in D:\Source\GaugeProject5\GaugeProject5\specs\example.spec. Make sure that installed test discoverers & executors, platform & framework version settings are appropriate and try again.
    ========== Run test finished: 0 run (0:00:30.4298276) ==========

Version Information

Microsoft Visual Studio Community 2015 Version 14.0.25431.01 Update 3 Microsoft .NET Framework Version 4.7.03062

Installed Version: Community

Gauge.VisualStudio 1.0 (as reported by Help > About) Gauge Visual Studio Extension

Gauge plugin for Visual Studio:- 0.3.7 Gauge.VisualStudio.Templates:- 1.1

gauge -v
Gauge version: 1.0.4
Commit Hash: 3a9a647

Plugins
-------
csharp (0.10.5)
html-report (4.0.8)
json-report (0.3.1)
xml-report (0.2.1)
nehashri commented 5 years ago

@ssg47 I wasn't able to see this error, but the the other issue on tests disappearing seems to be reproducible. I will see if this occurs after we fix the other issue

Debashis9012 commented 5 years ago

This issue has been verified and found fixed with the latest nightly of visual-studio.