dotnet/roslyn

Generate expected source file for the whole unit test session

Open

#26,161 opened on Apr 14, 2018

View on GitHub
 (4 comments) (0 reactions) (0 assignees)C# (20,414 stars) (4,257 forks)batch import
Area-CompilersTesthelp wanted

Description

I found this method in the test suite: TryGenerateExpectedSourceFileAndGetDiffLink

It generates the whole source file with just the expected assertion string replaced with actual.

It has some limitations and cannot be used for bulk baseline changes,

  • It only works if a diff tool is available
  • It only works for a single test

The most needed methods that need to have this is VerifyIL and VerifyDiagnostics mainly in case of bulk baseline changes.

The idea is that to keep a single file and apply new changes to that file so the expected source file contains changes for all tests in the file.

However, in order to do that, we should keep track of line numbers because they might get out of date once a test expected string is updated in the source.

Also, since VerifyDiagnostics accepts a params, we can't have line number at all. maybe fallback to stackframe? (my motivating use case for this feature request https://github.com/dotnet/csharplang/issues/1458)

Thoughts?

/cc @tmat

Contributor guide