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

append loader exceptions to error output #1296

Merged

Conversation

szaliszali
Copy link
Contributor

@szaliszali szaliszali commented Oct 5, 2018

Fixes #1293

extend TestTracer.TraceError

  • check if caught exception is a ReflectionTypeLoadException
  • append the loader exceptions to SpecFlow output

image

Types of changes

  • Bug fix (non-breaking change which fixes an issue).
  • New feature (non-breaking change which adds functionality).
  • Breaking change (fix or feature that would cause existing functionality to not work as expected).

Checklist:

  • I've added tests for my code.
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I have added an entry to the changelog

@szaliszali szaliszali changed the title WIP append loader exceptions to error output append loader exceptions to error output Oct 6, 2018
@szaliszali szaliszali changed the title append loader exceptions to error output WIP append loader exceptions to error output Oct 7, 2018
@SabotageAndi
Copy link
Contributor

Nice PR!

@szaliszali szaliszali changed the title WIP append loader exceptions to error output append loader exceptions to error output Oct 9, 2018
@szaliszali
Copy link
Contributor Author

@SabotageAndi I think it's ready for review

I could not add an automated test for the last case because I could not generate a solution with multiple assemblies using the test project generator.

On @icnocop 's test project the loader errors are printed to stdout through the tracer and the exception is rethrown (I reverted that catch block, so that part is unchanged)

<TestRun ....>
[....]
  <ResultSummary outcome="Failed">
    <Counters total="1" executed="1" error="0" failed="1" timeout="0" aborted="0" inconclusive="0" passedButRunAborted="0" notRunnable="0" notExecuted="0" disconnected="0" warning="0" passed="0" completed="0" inProgress="0" pending="0" />
    <Output>
      <StdOut>-&gt; Using app.config
-&gt; error: Unable to load one or more of the requested types. Retrieve the LoaderExceptions property for more information.
-&gt; error: Type Loader exceptions:
-&gt; error: LoaderException: System.IO.FileNotFoundException: Could not load file or assembly 'Microsoft.VisualStudio.TestTools.UITest.Extension.Silverlight, Version=11.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The system cannot find the file specified.
File name: 'Microsoft.VisualStudio.TestTools.UITest.Extension.Silverlight, Version=11.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'

WRN: Assembly binding logging is turned OFF.
To enable assembly bind failure logging, set the registry value [HKLM\Software\Microsoft\Fusion!EnableLog] (DWORD) to 1.
Note: There is some performance penalty associated with assembly bind failure logging.
To turn this feature off, remove the registry value [HKLM\Software\Microsoft\Fusion!EnableLog].

</StdOut>
    </Output>
  </ResultSummary>
[....]
  <Results>
    <UnitTestResult executionId="9023b9d3-b616-4831-a11a-60ac068725ab" testId="a4d4bb77-6d20-bde9-302e-03a2b557dafc" testName="Test" computerName="IE11WIN8_1" startTime="2018-10-08T23:02:39.2511726-07:00" endTime="2018-10-08T23:02:39.6262525-07:00" testType="13cdc9d9-ddb5-4fa4-a97d-d965ccfc6d4b" outcome="Failed" testListId="8c84fa94-04c1-424b-9868-57a2d4851a1d" relativeResultsDirectory="9023b9d3-b616-4831-a11a-60ac068725ab">
      <Output>
        <ErrorInfo>
          <Message>Class Initialization method CodedUITestProject4.SpecFlowFeature1Feature.FeatureSetup threw exception. System.Reflection.ReflectionTypeLoadException: System.Reflection.ReflectionTypeLoadException: Unable to load one or more of the requested types. Retrieve the LoaderExceptions property for more information..</Message>
          <StackTrace>    at System.Reflection.RuntimeModule.GetTypes(RuntimeModule module)
   at System.Reflection.RuntimeModule.GetTypes()
   at System.Reflection.Assembly.GetTypes()
   at TechTalk.SpecFlow.Bindings.Discovery.RuntimeBindingRegistryBuilder.BuildBindingsFromAssembly(Assembly assembly) in C:\devel\GitHub\SpecFlow\TechTalk.SpecFlow\Bindings\Discovery\RuntimeBindingRegistryBuilder.cs:line 22
   at TechTalk.SpecFlow.TestRunnerManager.BuildBindingRegistry(IEnumerable`1 bindingAssemblies) in C:\devel\GitHub\SpecFlow\TechTalk.SpecFlow\TestRunnerManager.cs:line 94
   at TechTalk.SpecFlow.TestRunnerManager.InitializeBindingRegistry(ITestRunner testRunner) in C:\devel\GitHub\SpecFlow\TechTalk.SpecFlow\TestRunnerManager.cs:line 69
   at TechTalk.SpecFlow.TestRunnerManager.CreateTestRunner(Int32 threadId) in C:\devel\GitHub\SpecFlow\TechTalk.SpecFlow\TestRunnerManager.cs:line 58
   at TechTalk.SpecFlow.TestRunnerManager.GetTestRunnerWithoutExceptionHandling(Int32 threadId) in C:\devel\GitHub\SpecFlow\TechTalk.SpecFlow\TestRunnerManager.cs:line 144
   at TechTalk.SpecFlow.TestRunnerManager.GetTestRunner(Int32 threadId) in C:\devel\GitHub\SpecFlow\TechTalk.SpecFlow\TestRunnerManager.cs:line 131
   at TechTalk.SpecFlow.TestRunnerManager.GetTestRunner(Assembly testAssembly, Nullable`1 managedThreadId) in C:\devel\GitHub\SpecFlow\TechTalk.SpecFlow\TestRunnerManager.cs:line 203
   at CodedUITestProject4.SpecFlowFeature1Feature.FeatureSetup(TestContext testContext)
</StackTrace>
        </ErrorInfo>
      </Output>
    </UnitTestResult>
  </Results>
</TestRun>```

@SabotageAndi
Copy link
Contributor

@szaliszali looks good for me. Thanks for the work!

@SabotageAndi SabotageAndi added this to the SpecFlow 3.0 milestone Oct 9, 2018
@SabotageAndi SabotageAndi merged commit 5ec54eb into SpecFlowOSS:master Oct 9, 2018
@Stephen-Mc
Copy link
Contributor

Thanks for your contribution to SpecFlow. If you would like us to send you some SpecFlow stickers as a thank you, please fill out the form here.

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