JsonSerializationException running tests from Microsoft.VisualStudio.Composition repo
Description
Attempting to run tests generates:
Starting test execution, please wait...
Passed EqualsConsidersMetadataWithArrays
Passed EqualsConsidersImportingConstructorRef
Error: The active Test Run was aborted.
Total tests: 2. Passed: 2. Failed: 0. Skipped: 0.
Test Run Failed.
Test execution time: 7.7736 Seconds
Steps to reproduce
- Copy binaries from
\\mlangfs1\public\kevinh\VSMEF.Binaries "C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\Common7\IDE\Extensions\qgyll0uu.4m0\vstest.console.exe" /testadapterPath:. Microsoft.VisualStudio.Composition.Tests.dll
Expected behavior
When using vstest.console.exe that lives next to TestExplorer, I get:
Passed...
...
Total tests: 1660. Passed: 1648. Failed: 0. Skipped: 12.
Test Run Successful.
Test execution time: 29.2140 Seconds
Actual behavior
Executing tests fails with "Error: The active Test Run was aborted."... Exception from log:
TpTrace Error: 0 : 13820, 4, 2017/01/12, 11:08:08.799, 600820657245, vstest.console.exe, Server: TestExecution: Aborting test run because Newtonsoft.Json.JsonSerializationException: Error setting value to 'StoreKeyValuePairs' on 'Microsoft.VisualStudio.TestPlatform.ObjectModel.TestCase'. ---> System.FormatException: An item with the same key has already been added. ---> System.ArgumentException: An item with the same key has already been added.
at System.ThrowHelper.ThrowArgumentException(ExceptionResource resource)
at System.Collections.Generic.Dictionary`2.Insert(TKey key, TValue value, Boolean add)
at ReadArrayOfKeyValueOfstringstringFromJson(XmlReaderDelegator , XmlObjectSerializerReadContextComplexJson , XmlDictionaryString , XmlDictionaryString , CollectionDataContract )
at System.Runtime.Serialization.Json.JsonCollectionDataContract.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)
at System.Runtime.Serialization.Json.DataContractJsonSerializer.ReadObject(XmlDictionaryReader reader)
at System.Runtime.Serialization.Json.DataContractJsonSerializer.ReadObject(Stream stream)
at Microsoft.VisualStudio.TestPlatform.ObjectModel.CustomKeyValueConverter.ConvertFrom(ITypeDescriptorContext context, CultureInfo culture, Object value)
at Microsoft.VisualStudio.TestPlatform.ObjectModel.TestObject.ConvertPropertyFrom[T](TestProperty property, CultureInfo culture, Object value)
--- End of inner exception stack trace ---
at Microsoft.VisualStudio.TestPlatform.ObjectModel.TestObject.ConvertPropertyFrom[T](TestProperty property, CultureInfo culture, Object value)
at Microsoft.VisualStudio.TestPlatform.ObjectModel.TestObject.SetPropertyValue[T](TestProperty property, T value, CultureInfo culture)
at Microsoft.VisualStudio.TestPlatform.ObjectModel.TestObject.set_StoreKeyValuePairs(List`1 value)
at SetStoreKeyValuePairs(Object , Object )
at Newtonsoft.Json.Serialization.DynamicValueProvider.SetValue(Object target, Object value)
--- End of inner exception stack trace ---
at Newtonsoft.Json.Serialization.DynamicValueProvider.SetValue(Object target, Object value)
at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.SetPropertyValue(JsonProperty property, JsonConverter propertyConverter, JsonContainerContract containerContract, JsonProperty containerProperty, JsonReader reader, Object target)
at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.PopulateObject(Object newObject, JsonReader reader, JsonObjectContract contract, JsonProperty member, String id)
at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateObject(JsonReader reader, Type objectType, JsonContract contract, JsonProperty member, JsonContainerContract containerContract, JsonProperty containerMember, Object existingValue)
at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateValueInternal(JsonReader reader, Type objectType, JsonContract contract, JsonProperty member, JsonContainerContract containerContract, JsonProperty containerMember, Object existingValue)
at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.PopulateList(IList list, JsonReader reader, JsonArrayContract contract, JsonProperty containerProperty, String id)
at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateList(JsonReader reader, Type objectType, JsonContract contract, JsonProperty member, Object existingValue, String id)
at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateValueInternal(JsonReader reader, Type objectType, JsonContract contract, JsonProperty member, JsonContainerContract containerContract, JsonProperty containerMember, Object existingValue)
at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.ResolvePropertyAndCreatorValues(JsonObjectContract contract, JsonProperty containerProperty, JsonReader reader, Type objectType)
at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateObjectUsingCreatorWithParameters(JsonReader reader, JsonObjectContract contract, JsonProperty containerProperty, ObjectConstructor`1 creator, String id)
at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateNewObject(JsonReader reader, JsonObjectContract objectContract, JsonProperty containerMember, JsonProperty containerProperty, String id, Boolean& createdFromNonDefaultCreator)
at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateObject(JsonReader reader, Type objectType, JsonContract contract, JsonProperty member, JsonContainerContract containerContract, JsonProperty containerMember, Object existingValue)
at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateValueInternal(JsonReader reader, Type objectType, JsonContract contract, JsonProperty member, JsonContainerContract containerContract, JsonProperty containerMember, Object existingValue)
at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.Deserialize(JsonReader reader, Type objectType, Boolean checkAdditionalContent)
at Newtonsoft.Json.JsonSerializer.DeserializeInternal(JsonReader reader, Type objectType)
at Newtonsoft.Json.Linq.JToken.ToObject(Type objectType, JsonSerializer jsonSerializer)
at Newtonsoft.Json.Linq.JToken.ToObject[T](JsonSerializer jsonSerializer)
at Microsoft.VisualStudio.TestPlatform.CommunicationUtilities.JsonDataSerializer.DeserializePayload[T](Message message)
at Microsoft.VisualStudio.TestPlatform.CommunicationUtilities.TestRequestSender.ListenAndReportTestResults(ITestRunEventsHandler testRunEventsHandler)
Environment
vstest.console.exe version 15.0.0.0
Seems like the same issue as https://github.com/Microsoft/vstest/pull/328. @navin22 can you confirm?
Yes, this issue has been fixed as part of #328. I have tested the above test dll with the latest bits. And able to get the same results. Total tests: 1660. Passed: 1648. Failed: 0. Skipped: 12. Test Run Successful.
@KevinH-MS can you try the latest master build vsix from here.
@sbaid @navin22 is this available in any VS builds yet (d15rel or d15prerel)?
Thanks
@sbaid @navin22 I tried this in the latest d15rel (26116.0), but it still repros. Is this fixed in d15prerel?
/CC @ManishJayaswal