-
Notifications
You must be signed in to change notification settings - Fork 783
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
New testing proposal #9418
New testing proposal #9418
Conversation
This is WIP, some tests in CI can be failing, I've created the PR for discussions and CI testing mostly. |
Another alternative is using FsCheck also as are runner, and use it also for the example-based test. Fairly reasonable alternative, given it's already used in the code base anyway. |
can't say I'm a big fan of the xUnit change. I know it's used in C# dotnet/* but from F# perspective we had just so many spooky bugs in the ecosystem and always had to work around those things. In the end it's your decision - I personally don't think it a good one. |
@Krzysztof-Cieslak Thanks, Krzysztof, I will take a look at it. I personally never used it myself as a runner. |
I think one of the benefits I've experienced with Expecto is the ability to make arbitrary decisions e.g. different tests for different builds without the need to jump through hoops to find different Theories and stuff. Seems like this is an issue cropping up even on the C# team. |
@vzarytovskii IIRC binding redirects issues, appdomain loading, package dependency issues, runner package issues, VS adapter issues ... - Most of those things are most likely obsolete in new shiney dotnet world, but whenever we run into issues it was very hard to communicate the problems to the project author. So I had to put xUnit work arounds into FAKE and Paket so that our users could work with xUnit. I'm not very happy about this to say the least. |
FCS solution is also a part of this repository and shares files (including test ones) with other solutions. We work with this solution only (and it's presumably the same for some other scenarios where FCS solution is used), please update it too. For some reason NUnit was always easier to set up for me, but I can't share any particular example. If making it use xUnit adds some considerable benefit let's change it, but currently I'm fine with FCS tests being NUnit ones. |
Yes, just confirming that FCS tests should also be considered here. We definitely don't want them to be orphaned. The IDE unit test suites and FCS tests cover a lot of shared concerns. Eventually it would be good to de-duplicate those concerns and have the IDE tests only cover IDE logic and have the FCS tests contain the bulk of testing specific to the compiler service. |
Is there any real need or concrete benefit to change to xunit? Or is it
mainly because rest of dotnet/* is using it?
I know this is bike shedding and mostly personal opinion - but from
developer standpoint I'd always go expecto (or similar) + fscheck. It's
just so much better to have no runner at all. It almost always wins from
dev tooling aspect.
But in the end I think the decision maker should be the person that
maintains all this stuff. That person needs to be happy. Contributers like
myself are not using it that much anyway.
Phillip Carter <notifications@github.com> schrieb am Mi., 10. Juni 2020,
18:45:
… Yes, just confirming that FCS tests should also be considered here. We
definitely don't want them to be orphaned. The IDE unit test suites and FCS
tests cover a lot of shared concerns. Eventually it would be good to
de-duplicate those concerns and have the IDE tests only cover IDE logic and
have the FCS tests contain the bulk of testing specific to the compiler
service.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#9418 (comment)>, or
unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAAOANFJ4KAODZJXUZCOX4TRV62DHANCNFSM4N2LFNVA>
.
|
It's this + personal preference mostly. xUnit and NUnit are frameworks I'm most familiar with.
I don't have much experience using Expecto in big projects like. I don't mind using it though, if everyone agrees :) I know @cartermp had some opinions about it. |
I'll say that I love expecto, but there is a persistent deadlock bug on the processing that we hit a few times a week at work with it. Recent fixes have helped, but I would take that into consideration. |
Thanks, I will change it as well.
I guess it's just more of a personal preference + adopting what other dotnet teams are using. NUnit, in my opinion, is a bit more "bloated" than xUnit. |
Thanks for the info! |
Expecto would be an interesting choice. There are... things that happened. @cartermp will know if you ask him ;-) |
From what I've read and found about expecto, is that people are having some random hangs on bigger projects. I've never encountered this myself though. |
Oh, technically it's fine in my experience - I've been using it with a success in whole bunch of projects :-) |
I'm more talking about the model. Not so much about expecto itself. Anyway most important thing is: this is now addressed systematically. Choice of test framework is not so important. Sorry for derailing the discussion. |
That is absolutely fine, I really appreciate the input :) I don't just want to go, change the framework and structure, I really want to have feedback from community, so everyone is happy :) |
It would be interesting to see if it affects performance of running the test suite, especially in the CI environment. |
I would love to be able to run/debug a specific test from ionide without having to muck with VsTests' VSHOST_DEBUG environment variable to attach to the running process or whatever the arcane combination to do that is. Any solution that can do that is A-ok by me! |
I will for sure have some data gathered from both old and new runs to compare them. |
It sounds like there's a trade-off between:
Is there a best-of-both-worlds approach? Are there improvements that we can try to make in XUnit or existing XUnit/F# bridge libraries? Also, does the shift in the F# infrastructure away from .NET Framework and toward .NET Core / .NET 5 change the calculus on anyone's opinions about the testing frameworks we've discussed? |
@forki - you asked about the switch to xunit. The ci that we use is aware of xunit testing, loging and the like. Right now we have additional scripts that smooth out some of the differences between the two frameworks within the CI. We would prefer to get rid of our special cases, and rely on the native CI behaviors. Kevin |
How does language testing fit into the proposed categorization scheme. A large portion of our test codebase seems to exist in-order verify that specific language constructs compile and produce executable output. For example: Example types of tests: I have no real intuition about what this should look like, but I would appreciate your thoughts on how we might arrange these, so that it is fairly clear where a new test belongs.. |
@vzarytovskii - Thanks Kevin |
My idea is to organize the compiler tests into separate suite(s) of component tests which will be testing certain categories (e.g. codegen, IL r/w, interop, etc.).
To be honest, I did not even consider using NCrunch at this point, due to its licensing (correct me if I'm wrong, but I thought that NC is commercial software, with no OSS license). And I'm unaware of any suitable alternatives which would support both desktop and coreclr. |
From my experience with ncrunch I would not make that a priority. It's an
awesome tool and seeing those red and green bubbles along the covered code
is amazing. But it's really hard to setup properly and to maintain it.
From my experience you get most of the same with just expecto style testing
and dotnet watch run. You don't have the code coverage, but you do have
that constant feedback loop. Which is the important part IMHO
Vlad Zarytovskii <notifications@github.com> schrieb am Do., 11. Juni 2020,
10:55:
… @KevinRansom <https://github.com/KevinRansom>
How does language testing fit into the proposed categorization scheme. A
large portion of our test codebase seems to exist in-order verify that
specific language constructs compile and produce executable output.
I have no real intuition about what this should look like, but I would
appreciate your thoughts on how we might arrange these, so that it is
fairly clear where a new test belongs..
My idea is to organize the compiler tests into separate suite(s) of
component tests which will be testing certain categories (e.g. codegen, IL
r/w, interop, etc.).
The first step is to start moving out of cambridge & FSharpQA suites
towards separate xUnit ones, so we can have it runnable/debugable on the
standard test platform.
forgive me if I overlooked it, but have you considered a continuous
testing framework such as NCrunch, should we organize testing in order to
make continuous testing usable and useful if so how would that look?
To be honest, I did not even consider using NCrunch at this point, due to
its licensing (correct me if I'm wrong, but I thought that NC is commercial
software, with no OSS license). And I'm unaware of any suitable
alternatives which would support both desktop and coreclr.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#9418 (comment)>, or
unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAAOANHES2YGE2EFZ5UIRJDRWCLZNANCNFSM4N2LFNVA>
.
|
@vzarytovskii -- As I understand it, there are developers who like to use it as part of their workflow. Have we considered, whether the changes we make would suit such a workflow? Kevin |
As far as I know, NCrunch is compatible with all modern frameworks and I expect it (and live unittesting) work just fine with xUnit. In fact, after the initial migration it will be a separate goal - to enable these sorts of scenarios for our tests. |
We should just simply use If we find that using other libraries would benefit us, we should discuss about bringing them in when the time comes. I know Also, I strongly encourage everyone to please look at how the Roslyn compiler tests are done. IMO, they make it very simple. |
@@ -39,6 +40,7 @@ | |||
<PackageReference Include="Microsoft.CodeAnalysis.Workspaces.Common" Version="$(MicrosoftCodeAnalysisWorkspacesCommonVersion)" /> | |||
<PackageReference Include="Microsoft.CodeAnalysis.CSharp" Version="$(MicrosoftCodeAnalysisCSharpVersion)" /> | |||
<PackageReference Include="Microsoft.CodeAnalysis.Test.Resources.Proprietary" Version="$(MicrosoftCodeAnalysisTestResourcesProprietaryVersion)" /> | |||
<PackageReference Include="NUnit" Version="$(NUnitVersion)" /> | |||
<PackageReference Include="NUnit" Version="$(NUnitVersion)" /> <!-- TODO: This should be removed once all NUnit frameworks are migrated to xUnit --> | |||
<PackageReference Include="FluentAssertions" Version="$(FluentAssertionsVersion)" /> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Out of curiosity, is FluentAssertions
giving benefit to any of the current tests?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess only a bit better assertion messages. They seem more readable to me.
Enabling NCrunch doesn't require that we do anything special in the repo. It's not a library dependency. In practice it works reliably until you overcustomize a build. Keeping the build simple has other virtues anyway, so I think it's worthwhile to keep this kind of workflow within reach. |
I would agree with @TIHan here. We should start with plain simple xUnit here and then add other dependencies when needed as we migrate more tests and scenarios. |
Would it be possible to replace the printf "magic" with some simple formatting functions on the top during the migration ? To avoid issues like this: #4954 as it would help improve the F# test coverage on platforms / runtimes / targets like Mono AOT, WebAssembly, Fable, Fez, etc. |
…ages' to it for 2nd time).
Hm, great feedback on tests, thanks. I will need to look at it more thoroughly though. Most likely, won’t be a part of this particular PR. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks like a great start.
@@ -3,14 +3,15 @@ namespace FSharp.Compiler.UnitTests | |||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should the test files be all in the same directory ByteMemoryTests.fs, EditDistance.fs, HashIfExpression.fs.
or should they be further differentiated, it's just that I imagine eventually Compiler.ComponentTest would have a huge number of files in it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@KevinRansom my idea was grouping files by the directories inside the test suites (e.g. Compiler.ComponentTests). But they can as well be factored out into separate suite if will grow in size.
As part of our initiative of F# tests reworking, I would like to submit a proposal PR for new tests structure, frameworks, goals, and some initial prerequisites implementation.
I would really appreciate any feedback and additions.
F# Testing proposal
Why do we test
Goals
Framework for testing
The following test frameworks and libraries will be used for new test projects xUnit Test Framework, FluentAssertions (+ FsUnit and FsCheck when needed). All existing NUnit test suites will be migrated to xUnit.
Justification:
Alternatives: NUnit, MSBuild, Expecto
Tests categorization
New tests should be grouped based on two factors: test type (1) + test category and subcategory (2)
Determines what type of test is it:
Examples
Compiler
and subcategoriesEmittedIL
andComputationExpressions
.Compiler.Service
and subcategoryTokenizer
.Please, refer to File and project structure for more information on how tests will be organized on the filesystem.
File and project structure
Naming schema
The proposed naming schema for test projects is:
FSharp.Category.Subcategory.TestType
, whereCategory.Subcategory
is either a corresponding source project, or a more generic component (e.g.Compiler
,Compiler.Private
or more granularCompiler.CodeGen
,Compiler.CodeGen.EmittedIL
if category or subcategory project becomes too big, etc.) andTestType
is the type of the test (one ofUnitTests
,ComponentTests
,IntegrationTests
,LoadTests
).Projects organization
Please refer to the "Naming schema" section above for more information on the projects naming.
New test projects will be grouped by category and test type, all subcategories are just test folders/files in the test project.
Examples: Having test project organized like:
Will result in one test dll "
FSharp.Compiler.ComponentTests.dll
" which will contain all the subcategories of tests.Notes:
Test Utilities/Helpers
For all new and migrated tests, any common/helper functionality shall be factored out to a separate project -
FSharp.Test.Utilities
.New tests
Trait
, based on theirCategory
andSubcategories
.Migrating existing tests
Existing FSharpQA and Cambridge need to be migrated to corresponding test projects: component-style tests to the
FSharp.Compiler.ComponentTests
and unittest-style tests -FSharp.Compiler.UnitTests
,FSharp.Compiler.Private.Scripting.UnitTests
,FSharp.Build.UnitTests
, etc.Next steps
NUnit
tests to xUnit.Open questions:
Other
Related issues: (#7075)
You can find this document under 'tests/README.md'.