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

Refactor Integration Tests to separate DBMS tests from driver tests #698

Closed
Ste1io opened this issue Sep 30, 2023 · 2 comments · Fixed by #701
Closed

Refactor Integration Tests to separate DBMS tests from driver tests #698

Ste1io opened this issue Sep 30, 2023 · 2 comments · Fixed by #701
Assignees

Comments

@Ste1io
Copy link
Collaborator

Ste1io commented Sep 30, 2023

Currently there is no distinction between DBMS tests and supported drivers/libraries. This creates both ambiguity, and results in duplicate code.

Adding an additional inheritance level for driver tests, which inherit from DBMS tests, would remove the duplicate test code that's DBMS specific, and encapsulate driver-specific tests moving forward.

@Ste1io Ste1io self-assigned this Sep 30, 2023
@Ste1io
Copy link
Collaborator Author

Ste1io commented Sep 30, 2023

The least-intrusive refactor requiring minimal structural changes (afaik) is below. An alternative approach would be to move "DriverTests" out into a sibling directory that mirrors "DbmsTests", and move the base tests out next to both of them. Both approaches would still use the same inheritance structure, namely Drivers -> Dbms -> Base.

Dbms tests would need to override both constructors that BaseTests offers; otherwise, the inheritance should work fine as-is.

Feedback certainly welcome.

PetaPoco\PetaPoco.Tests.Integration\.
│   AppSetting.cs
│   appsettings.json
│   PetaPoco.Tests.Integration.csproj
│
├───Databases
│   │   # Base test classes
│   │   DBTestProvider.cs
│   │   BaseDatabase.cs
│   │   BaseDatabaseTests.cs
│   │   BaseExecuteTests.cs
│   │   BaseQueryTests.cs
│   │   ...
│   │   
│   ├───MSSql
│   │   │   # MS SQL DBMS tests
│   │   │   MSSqlDbmsDatabaseTests.cs
│   │   │   MSSqlDbmsDBTestProvider.cs
│   │   │   MSSqlDbmsExecuteTests.cs
│   │   │   MSSqlDbmsQueryTests.cs
│   │   │   ...
│   │   │
│   │   ├───SystemData
│   │   │       # MS SQL driver tests for legacy "System.Data.SqlClient"
│   │   │       MSSqlDatabaseTests.cs
│   │   │       MSSqlTestProvider.cs
│   │   │       MSSqlExecuteTests.cs
│   │   │       MSSqlQueryTests.cs
│   │   │       ...
│   │   │
│   │   └───MSData
│   │           # MS SQL driver tests for modern "Microsoft.Data.SqlClient"
│   │           MSSqlMsDataDatabaseTests.cs
│   │           MSSqlMsDataDBTestProvider.cs
│   │           MSSqlMsDataExecuteTests.cs
│   │           MSSqlMsDataQueryTests.cs
│   │           ...
│   │
│   ├───Postgres
│   │   │   # Postgres Dbms tests
│   │   │   PostgresDbmsDatabaseTests.cs
│   │   │   PostgresDbmsDBTestProvider.cs
│   │   │   PostgresDbmsExecuteTests.cs
│   │   │   PostgresDbmsQueryTests.cs
│   │   │   ...
│   │   │
│   │   └───Npgsql
│   │           # Postgres driver tests for "Npgsql"
│   │           PostgresNpgsqlDatabaseTests.cs
│   │           PostgresNpgsqlDBTestProvider.cs
│   │           PostgresNpgsqlExecuteTests.cs
│   │           PostgresNpgsqlQueryTests.cs
│   │           ...
│   │           
│   └───...
│
├───Models
│   │   BugInvestigations.cs
│   │   Note.cs
│   │   Order.cs
│   │   Person.cs
│   │   ...
│   │
│   └───MSSql
│           StorePerson.cs
│
└───Scripts
        MSSQLBuildDatabase.sql
        PostgresBuildDatabase.sql
        ...

@Ste1io
Copy link
Collaborator Author

Ste1io commented Oct 7, 2023

Should have a PR ready to open this weekend. Any issues with using child classes for the drivers @pleb @asherber?

1696676571-PetaPoco_-_Microsoft_Visual_Studio

1696676972-PetaPoco_-_Microsoft_Visual_Studio

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

Successfully merging a pull request may close this issue.

1 participant