2017-10-12 145 views
0

我有一個測試框架,我們打算使用Codedui以及specflow。我已經安裝的工具分開過,但我目前在與這兩個工具運行specflow測試得到一個錯誤裝在一起:Visual Studio 2017 SpecFlow和CodedUI程序集無法加載

[10/12/2017 12:02:00 AM Informational] ------ Discover test started ------ 
[10/12/2017 12:02:01 AM Informational] NUnit Adapter 3.8.0.0: Test discovery starting 
[10/12/2017 12:02:01 AM Informational] NUnit Adapter 3.8.0.0: Test discovery complete 
[10/12/2017 12:02:01 AM Informational] NUnit VS Adapter 2.1.1.0 discovering tests is started 
[10/12/2017 12:02:01 AM Warning] Dependent Assembly Microsoft.VisualStudio.QualityTools.CodedUITestFramework, Version=15.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a of C:\Users\*****\documents\visual studio 2017\Projects\*****\*****\bin\Debug\*****.dll not found. Can be ignored if not a NUnit project. 
[10/12/2017 12:02:01 AM Informational] NUnit VS Adapter 2.1.1.0 discovering test is finished 
[10/12/2017 12:02:01 AM Informational] ========== Discover test finished: 2 found (0:00:00.2788078) ========== 
[10/12/2017 12:02:01 AM Informational] ------ Run test started ------ 
[10/12/2017 12:02:01 AM Informational] NUnit Adapter 3.8.0.0: Test execution started 
[10/12/2017 12:02:01 AM Informational] Running selected tests in C:\Users\******\documents\visual studio 2017\Projects\******\******\bin\Debug\******.dll 
[10/12/2017 12:02:01 AM Informational] NUnit3TestExecutor converted 1 of 1 NUnit test cases 
[10/12/2017 12:02:01 AM Warning] TearDown failed for test fixture ******.Specflow.Features.SpecFlowFeature1Feature 
[10/12/2017 12:02:01 AM Warning] System.IO.FileNotFoundException : Could not load file or assembly 'Microsoft.VisualStudio.QualityTools.CodedUITestFramework, Version=15.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The system cannot find the file specified. 
TearDown : System.NullReferenceException : Object reference not set to an instance of an object. 
[10/12/2017 12:02:01 AM Warning] at System.ModuleHandle.ResolveType(RuntimeModule module, Int32 typeToken, IntPtr* typeInstArgs, Int32 typeInstCount, IntPtr* methodInstArgs, Int32 methodInstCount, ObjectHandleOnStack type) 
    at System.ModuleHandle.ResolveTypeHandleInternal(RuntimeModule module, Int32 typeToken, RuntimeTypeHandle[] typeInstantiationContext, RuntimeTypeHandle[] methodInstantiationContext) 
    at System.Reflection.RuntimeModule.ResolveType(Int32 metadataToken, Type[] genericTypeArguments, Type[] genericMethodArguments) 
    at System.Reflection.CustomAttribute.FilterCustomAttributeRecord(CustomAttributeRecord caRecord, MetadataImport scope, Assembly& lastAptcaOkAssembly, RuntimeModule decoratedModule, MetadataToken decoratedToken, RuntimeType attributeFilterType, Boolean mustBeInheritable, Object[] attributes, IList derivedAttributes, RuntimeType& attributeType, IRuntimeMethodInfo& ctor, Boolean& ctorHasParameters, Boolean& isVarArg) 
    at System.Reflection.CustomAttribute.GetCustomAttributes(RuntimeModule decoratedModule, Int32 decoratedMetadataToken, Int32 pcaCount, RuntimeType attributeFilterType, Boolean mustBeInheritable, IList derivedAttributes, Boolean isDecoratedTargetSecurityTransparent) 
    at System.Reflection.CustomAttribute.GetCustomAttributes(RuntimeType type, RuntimeType caType, Boolean inherit) 
    at System.RuntimeType.GetCustomAttributes(Type attributeType, Boolean inherit) 
    at TechTalk.SpecFlow.Bindings.Discovery.RuntimeBindingRegistryBuilder.BuildBindingsFromType(Type type) 
    at TechTalk.SpecFlow.Bindings.Discovery.RuntimeBindingRegistryBuilder.BuildBindingsFromAssembly(Assembly assembly) 
    at TechTalk.SpecFlow.TestRunnerManager.BuildBindingRegistry(IEnumerable`1 bindingAssemblies) 
    at TechTalk.SpecFlow.TestRunnerManager.InitializeBindingRegistry(ITestRunner testRunner) 
    at TechTalk.SpecFlow.TestRunnerManager.CreateTestRunner(Int32 threadId) 
    at TechTalk.SpecFlow.TestRunnerManager.GetTestRunner(Int32 threadId) 
    at TechTalk.SpecFlow.TestRunnerManager.GetTestRunner(Assembly testAssembly, Nullable`1 managedThreadId) 
    at *****.Specflow.Features.SpecFlowFeature1Feature.FeatureSetup() 
--TearDown 
    at *****.Specflow.Features.SpecFlowFeature1Feature.FeatureTearDown() 
[10/12/2017 12:02:01 AM Informational] NUnit Adapter 3.8.0.0: Test execution complete 
[10/12/2017 12:02:02 AM Informational] ========== Run test finished: 1 run (0:00:00.7393256) ========== 

我檢查了引用,好像「失蹤」參考Microsoft.VisualStudio.QualityTools.CodedUITestFramework列在我的參考資料中。還有什麼可能是這個問題?

+0

您是否嘗試解決缺失參考周圍的問題..如果不是這樣,那麼建議您先執行此操作.. –

回答

1

CodedUI僅適用於MSTest。 要使其與SpecFlow一起使用,您需要額外的插件。

請看看它的文檔:http://specflow.org/documentation/Using-SpecFlow-with-CodedUI-API/
你有趣的部分是:Getting SpecFlow to generate the [CodedUITest] attribute with Visual Studio 2013+ and MSTest

你需要一個定製SpecFlowCodedUITestGenerator它增加了需要Microsoft.VisualStudio.TestTools.UITesting.CodedUITestAttribute屬性,並從測試類的Microsoft.VisualStudio.TestTools.UnitTesting.TestClassAttribute屬性。

如何做到這一點的具體步驟是在文檔中。

+0

@AdrianHHH我明白,人們直接在此處獲得答案會更容易,因此我添加了一個更多信息。但是,鏈接到正式文檔的確是如何在SpecFlow中使用CodedUI的問題。那麼爲什麼重複的信息可能會過時? –

+0

這很好,但是似乎沒有關於如何在Specflow的最新版本上運行的信息。最新的我看到的是1.6到1.9。我目前使用Specflow 2.2.1。 –

相關問題