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

Guideline for Microsoft.EntityFrameworkCore.Relational.Specification.Tests #3664

Closed
guscuate opened this issue Jan 4, 2022 · 6 comments · Fixed by #3665
Closed

Guideline for Microsoft.EntityFrameworkCore.Relational.Specification.Tests #3664

guscuate opened this issue Jan 4, 2022 · 6 comments · Fixed by #3665

Comments

@guscuate
Copy link

guscuate commented Jan 4, 2022

Hello Team,
We would like to run your test suite into our data provider (MySQL Connector/Net), is there any documentation or guide about what is the right way to use Microsoft.EntityFrameworkCore.Relational.Specification.Tests package?

Regards.

@ErikEJ
Copy link
Contributor

ErikEJ commented Jan 4, 2022

Maybe look at how other providers use the package?

@roji
Copy link
Member

roji commented Jan 4, 2022

@guscuate great that you're looking at the specification tests! They're a very useful way of making sure your provider works well.

There's no documentation for using them, but it should be quite straightforward:

  1. Create your own test project (i.e. MySql.EntityFrameworkCore.FunctionalTests)
  2. Pick a test class from Microsoft.EntityFrameworkCore.Relational.Specification.Tests, and start extend it in your project. For example, you could start with NorthwindWhereQueryRelationalTestBase, which you'd extend from NorthwindWhereQueryMySqlTest.
  3. You'll have a bit of test infrastructure to implement first. For example, for NorthwindWhereQueryMySqlTest you'll have to implement NorthwindWhereQueryMySqlFixture, which will require a MySqlNorthwindTestStoreFactory, which would need a Northwind.sql script to seed the MySQL version of the Northwind database. I suggest keeping another EF Core provider's test suite open nearby, and simply following what it does (you can use the SQL Server provider's tests, or SQLite's or Npgsql's).
  4. Once the infrastructure for the test class is done, you'll start seeing some green tests on it. You can investigate the failing tests, or temporarily skip them for later investigation. In this way you can add more and more test classes.
  5. At some point, when you've extended most of the upstream test classes, you can also create MySqlComplianceTest, which extends RelationalComplianceTestBase. This has a test which will fail if your own test project doesn't extend an upstream test class - it's a great way to know whether your test suite is complete, and also whether we add a new test class on our side in a new version. You can also opt out of extending specific test classes if they're not ready (or not relevant).

I'd recommend giving the above a try - we'll be here to help with any concrete issues you come across!

PS #681 tracks adding documentation around this and other aspects of writing an EF Core provider.

@guscuate
Copy link
Author

guscuate commented Jan 4, 2022

Thank you very much for your responses this is very useful!.

@ajcvickers ajcvickers transferred this issue from dotnet/efcore Jan 6, 2022
@ajcvickers
Copy link
Member

Note from triage: put screenshot of this in docs. 😜

@ajcvickers ajcvickers added this to the 7.0.0 milestone Jan 6, 2022
roji added a commit to roji/EntityFramework.Docs that referenced this issue Jan 6, 2022
@roji roji closed this as completed in #3665 Jan 6, 2022
roji added a commit that referenced this issue Jan 6, 2022
@guscuate
Copy link
Author

guscuate commented Jan 6, 2022

Hi Roji, I saw you updated the documentation and you mentioned to create an Xunit project, is this strictly required or this can also work using a different test framework like Nunit?

@roji
Copy link
Member

roji commented Jan 6, 2022

@guscuate the specification test suite itself is written using xunit, so you'll have to use xunit as well.

Note that this doesn't preclude you from also having an additional test project using nunit or anything else. However, for an EF provider, the specification test suite should generally be the most important testing resource - so it's worth using it even if it isn't your preferred unit testing framework.

FWIW I prefer nunit to xunit (and use nunit in Npgsql), but I use xunit in the Npgsql EF provider for the specification test suite.

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

Successfully merging a pull request may close this issue.

4 participants