Testing: Having trouble running the tests
Hi @sjh37,
I am having some trouble with settings/running the tests
- Categorize the tests / database technologie.
- Have a "pre-test" to generate/recreate the db
- Have you every considered a package like Efcore.TestSupport to generate and manage the database.
- or maybe have some scripts to recreate the DB manually (with some instructions) for example, using Docker Desktop to run PostgreSql
- as with (local) also include some tests with (localdb)\MSSQLLocalDB
Hi @sjh37,
Just found this project: northwind_psql which has some script to create the northwind db under Postgre
@sjh37
In these tests, some artifacts seem to be pointing to your userprofile directories, and these are not in the SCC.
SingleDatabaseReverseEngineerTests.cs
L254 var subFolder = templateType == TemplateType.EfCore2 ? "TestComparison\EfCore2NorthwindSqlCe40" : "TestComparison\EfCore3NorthwindSqlCe40";
L332 var testRootPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.UserProfile), "OneDrive\Documents");
- can you please add these to the SCC ?
- can we use the var path = Path.Combine(Path.GetTempPath(), "POCO_Generator_Tests") ? instead of the profile/onedrive path
@sjh37 One more thing... When running the tests locally (ReverseEngineerSqlCe_EfCore) I am getting this result: Expected string length 45891 but was 45940. Strings differ at index 4899. Expected: "...UseSqlServer(@"Data Source=C:\S\Source (open source)\Entit..." But was: "...UseSqlServer(@"Data Source=C:\Users\bobby\source\Github\bo..." ---------------------------------------------^ Of course our local paths are not the same. Maybe do a "search/replace" to account for the path, just before comparing, that way we would not need to change the file in the SCC.
Hi Simon (@sjh37 ),
I have created a fork/branch and preparing a PR for your review, of course you are free to accept or not.
More details coming soon.
Hi Simon [@sjh37],
Did you release yet ? I would really like to revisit the unit tests project.
I would like to integrate the Sqlite part, but for that, I would like to be able to run the tests fully. And I could probably help with the MySql part as well.
Maybe I should first do :
- we would need the SQL script for the Postgre_northwind.sql
- we would need the SQL script for the Mssql_fred.sql
- Generator.Tests.Unit >> 1 PR
- Tester.Integration.EfCore3 >> 1 PR
Ef2 is dropping out of support.
Maybe we should move some of the tests from EfCore3 to Ef6;
N.b. we should consider consolidating the .NET Integration Tests by generating; that way upkeeping the unit tests for all versions; and we could use the pre-compile to exclude version specific (for example: netcoreapp2.1)
<TargetFramework>netcoreapp2.1;netcoreapp3.1;net5.0;net6.0</TargetFramework>
Hi Simon (@sjh37 );
The thing that initially broke.... can you check if it's not simply the fact that I had disabled the .pfx code signing from the main assembly (since I don't have the pwd)....
Hi Bobby, Yes I released last week. And made a start on integrating your #727 PR changes into the main branch. I'll continue doing that until most/all of your changes are in. You are right in that it can't be a snowflake for unit tests.
Thanks for all of your help, much appreciated. If you give me your email address, I'll send you a commercial licence as a thankyou.
I'll add in the postgresql northwind.sql
Thanks for all of your help, much appreciated. If you give me your email address, I'll send you a commercial licence as a thankyou.
I have sent you an email to the address listed on your github profile.
Thank you in advanced.
... You are right in that it can't be a snowflake for unit tests.
Instead of having integration test projects for EfCoreX etc.... => use muti-target
you should consider having a test project per Db technologies (or at the very least, having test categories)
- mssql (server, localdb, CE)
- postgre
- (mysql)
- (oracle)
- (sqlite)
- (in-memory)
n.b. these change would only affect your tests project, so your main product should not be affected.
I have checkout the EfCore code base, they have over 88,000 tests; and they use (localDb)\MSSQLLocalDb to run all their integration tests; you should consider this option to. Although supporting UserSecrets and removing hardcoded connection string from the test code will greatly help.
Also, using MSSQL, should you not consider integration tests against, V12, V14 (azure sql), V16, V17 ? This could be done using docker containers instances. but would require some scripting to setup the different environments. Could also be done using LocalDb with various instances, for example:
- (localDb)\V12
- (localDb)\V14
- (localDb)\V16
- (localDb)\MSSQLLocalDb (v17 latest)
I'll add in the
postgresql northwind.sql
It seems to be missing AlphabeticalListOfProducts
I have already added the northwind.sql for postgres, take a look at this changeset https://github.com/sjh37/EntityFramework-Reverse-POCO-Code-First-Generator/commit/1d80136b06c5ba2b4827c0d664b6e2a57f318bf2
I have already added the
northwind.sqlfor postgres, take a look at this changeset 1d80136
I am looking inside the file northwind.sql, there are no mention of any table named AlphabeticalListOfProducts; but there is a view called Alphabetical list of products.
I had found this .sql file from a northwind_psql it might not be exactly conform to your version of the postgre database you have. Can you please update the script to match ? alternatively adjust the dbcontext that are used in the tests ?
NOTE: Also, the file is name northwind.sql and is in the root; can we move it to a folder ? Eventually, we can have scripts for mysql, oracle, sqlite.
I looked at the SQL Server Northwind database and that does not have a table named AlphabeticalListOfProducts but does have a view called Alphabetical list of products.
It doesn't have to exactly the same as someone elses, as long as we can reverse engineer against it and test the output.
I looked at the SQL Server Northwind database and that does not have a table named
AlphabeticalListOfProductsbut does have a view calledAlphabetical list of products.It doesn't have to exactly the same as someone elses, as long as we can reverse engineer against it and test the output.
I agree. Maybe we should just adjust the comparison scrupt in TestComparason
Released v3.6.0 - This should improve testing. Still making testing better and less of a snowflake.