EntityFramework-Reverse-POCO-Code-First-Generator icon indicating copy to clipboard operation
EntityFramework-Reverse-POCO-Code-First-Generator copied to clipboard

Testing: Having trouble running the tests

Open bobbyangers opened this issue 4 years ago • 17 comments

Hi @sjh37,

I am having some trouble with settings/running the tests

  1. Categorize the tests / database technologie.
  2. 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
  3. as with (local) also include some tests with (localdb)\MSSQLLocalDB

bobbyangers avatar Nov 05 '21 20:11 bobbyangers

Hi @sjh37,

Just found this project: northwind_psql which has some script to create the northwind db under Postgre

bobbyangers avatar Nov 06 '21 00:11 bobbyangers

@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");

  1. can you please add these to the SCC ?
  2. can we use the var path = Path.Combine(Path.GetTempPath(), "POCO_Generator_Tests") ? instead of the profile/onedrive path

bobbyangers avatar Nov 06 '21 03:11 bobbyangers

@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.

bobbyangers avatar Nov 06 '21 03:11 bobbyangers

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.

bobbyangers avatar Nov 06 '21 20:11 bobbyangers

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 :

  1. we would need the SQL script for the Postgre_northwind.sql
  2. we would need the SQL script for the Mssql_fred.sql
  3. Generator.Tests.Unit >> 1 PR
  4. 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>

bobbyangers avatar Nov 15 '21 13:11 bobbyangers

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)....

bobbyangers avatar Nov 15 '21 14:11 bobbyangers

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.

sjh37 avatar Nov 15 '21 17:11 sjh37

I'll add in the postgresql northwind.sql

sjh37 avatar Nov 15 '21 17:11 sjh37

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.

bobbyangers avatar Nov 15 '21 18:11 bobbyangers

... 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)

  1. mssql (server, localdb, CE)
  2. postgre
  3. (mysql)
  4. (oracle)
  5. (sqlite)
  6. (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.

bobbyangers avatar Nov 15 '21 19:11 bobbyangers

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:

  1. (localDb)\V12
  2. (localDb)\V14
  3. (localDb)\V16
  4. (localDb)\MSSQLLocalDb (v17 latest)

bobbyangers avatar Nov 15 '21 19:11 bobbyangers

I'll add in the postgresql northwind.sql

It seems to be missing AlphabeticalListOfProducts

bobbyangers avatar Nov 18 '21 03:11 bobbyangers

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

sjh37 avatar Nov 18 '21 09:11 sjh37

I have already added the northwind.sql for 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.

bobbyangers avatar Nov 18 '21 14:11 bobbyangers

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.

sjh37 avatar Nov 22 '21 20:11 sjh37

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 agree. Maybe we should just adjust the comparison scrupt in TestComparason

bobbyangers avatar Nov 23 '21 02:11 bobbyangers

Released v3.6.0 - This should improve testing. Still making testing better and less of a snowflake.

sjh37 avatar Feb 13 '22 17:02 sjh37