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

Testing: Having trouble running the tests #726

Closed
bobbyangers opened this issue Nov 5, 2021 · 17 comments
Closed

Testing: Having trouble running the tests #726

bobbyangers opened this issue Nov 5, 2021 · 17 comments

Comments

@bobbyangers
Copy link
Contributor

bobbyangers commented Nov 5, 2021

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
Copy link
Contributor Author

Hi @sjh37,

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

@bobbyangers
Copy link
Contributor Author

@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
Copy link
Contributor Author

bobbyangers commented Nov 6, 2021

@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
Copy link
Contributor Author

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
Copy link
Contributor Author

bobbyangers commented Nov 15, 2021

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
Copy link
Contributor Author

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

@sjh37
Copy link
Owner

sjh37 commented Nov 15, 2021

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
Copy link
Owner

sjh37 commented Nov 15, 2021

I'll add in the postgresql northwind.sql

@bobbyangers
Copy link
Contributor Author

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
Copy link
Contributor Author

... 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
Copy link
Contributor Author

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
Copy link
Contributor Author

I'll add in the postgresql northwind.sql

It seems to be missing AlphabeticalListOfProducts

@sjh37
Copy link
Owner

sjh37 commented Nov 18, 2021

I have already added the northwind.sql for postgres, take a look at this changeset 1d80136

@bobbyangers
Copy link
Contributor Author

bobbyangers commented Nov 18, 2021

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.

@sjh37
Copy link
Owner

sjh37 commented Nov 22, 2021

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.

@bobbyangers
Copy link
Contributor Author

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

@sjh37
Copy link
Owner

sjh37 commented Feb 13, 2022

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

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

No branches or pull requests

2 participants