scaffolding-oracle-to-postgres-migration-test-project
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseScaffolding an Integration Test Project for Oracle-to-PostgreSQL Migration
搭建Oracle-to-PostgreSQL迁移的集成测试项目
Creates a compilable, empty xUnit test project with transaction management and seed data infrastructure for a single target project. Run once per project before writing tests.
创建一个可编译的空xUnit测试项目,包含事务管理和种子数据基础设施,对应单个目标项目。在编写测试前为每个项目运行一次。
Workflow
工作流程
Progress:
- [ ] Step 1: Inspect the target project
- [ ] Step 2: Create the xUnit test project
- [ ] Step 3: Implement transaction-rollback base class
- [ ] Step 4: Implement seed data manager
- [ ] Step 5: Verify the project compilesStep 1: Inspect the target project
Read the target project's to determine the .NET version and existing package references. Match these versions exactly — do not upgrade.
.csprojStep 2: Create the xUnit test project
- Target the same .NET version as the application under test.
- Add NuGet packages for Oracle database connectivity and xUnit.
- Add a project reference to the target project only — no other application projects.
- Add an configured for Oracle database connectivity.
appsettings.json
Step 3: Implement transaction-rollback base class
- Create a base test class that opens a transaction before each test and rolls it back after.
- Catch and handle all exceptions to guarantee rollback.
- Make the pattern inheritable by all downstream test classes.
Step 4: Implement seed data manager
- Create a global seed manager for loading test data within the transaction scope.
- Do not commit seed data — transactions roll back after each test.
- Do not use — preserve existing database data.
TRUNCATE TABLE - Reuse existing seed files if available.
- Establish a naming convention for seed file location that downstream test creation will follow.
Step 5: Verify the project compiles
Build the test project and confirm it compiles with zero errors before finishing.
进度:
- [ ] 步骤1: 检查目标项目
- [ ] 步骤2: 创建xUnit测试项目
- [ ] 步骤3: 实现事务回滚基类
- [ ] 步骤4: 实现种子数据管理器
- [ ] 步骤5: 验证项目可编译步骤1:检查目标项目
读取目标项目的文件,确定.NET版本和现有包引用。完全匹配这些版本——不要升级。
.csproj步骤2:创建xUnit测试项目
- 目标.NET版本与被测应用保持一致。
- 添加用于Oracle数据库连接和xUnit的NuGet包。
- 仅添加对目标项目的项目引用——不添加其他应用项目。
- 添加配置为Oracle数据库连接的文件。
appsettings.json
步骤3:实现事务回滚基类
- 创建一个基测试类,在每个测试前开启事务,测试后回滚事务。
- 捕获并处理所有异常,确保事务回滚。
- 该模式可被所有下游测试类继承。
步骤4:实现种子数据管理器
- 创建全局种子管理器,用于在事务范围内加载测试数据。
- 不要提交种子数据——每个测试后事务会回滚。
- 不要使用语句——保留现有数据库数据。
TRUNCATE TABLE - 如果有可用的现有种子文件,可复用。
- 为种子文件位置建立命名规范,供下游测试创建时遵循。
步骤5:验证项目可编译
构建测试项目,确认编译零错误后再完成。
Key Constraints
关键约束
- Oracle is the golden behavior source — scaffold for Oracle first.
- Keep to existing .NET and C# versions; do not introduce newer language or runtime features.
- Output is an empty test project with infrastructure only — no test cases.
- Oracle是基准行为源——优先为Oracle搭建脚手架。
- 保持现有.NET和C#版本;不要引入更新的语言或运行时特性。
- 输出仅为包含基础设施的空测试项目——无测试用例。