You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
refactor(BulkOperationTest): improve test lifecycle, sync helpers, and cleanup
Improve the test lifecycle, initialization, and teardown of Contentstack015_BulkOperationTest.
Test method signature changes:
- Convert Test000a_Should_Create_Workflow_With_Two_Stages from async Task to void
(no awaits were present; async keyword was unnecessary).
- Convert Test000b_Should_Create_Publishing_Rule_For_Workflow_Stage2 from async Task
to void; replace await EnsureBulkTestEnvironmentAsync with the new sync helper.
New synchronous helpers:
- Add GetAvailableEnvironments(Stack) — sync version of GetAvailableEnvironmentsAsync,
used by the new EnsureBulkTestEnvironment helper.
- Add EnsureBulkTestEnvironment(Stack) — sync version of EnsureBulkTestEnvironmentAsync,
finds or creates bulk_test_env without blocking on a Task.
TestInitialize improvements:
- Uncomment and add CreateTestEnvironment() and CreateTestRelease() calls so a new
stack gets test environment and release set up before each test.
- Add workflow initialization in TestInitialize: if _bulkTestWorkflowUid is not set
(e.g. ClassInitialize failed or new stack), call
EnsureBulkTestWorkflowAndPublishingRuleAsync to ensure workflow and publish rule
are available.
- Add full explicit try/catch blocks for each setup step with Console.WriteLine
logging and meaningful comments; workflow catch records the failure reason in
_bulkTestWorkflowSetupError so workflow-based tests surface it via AssertWorkflowCreated().
New cleanup test:
- Add Test009_Should_Cleanup_Test_Resources (void, DoNotParallelize) that deletes
all resources created during the test run in the correct order:
1. All entries in _createdEntries
2. Content type (bulk_test_content_type)
3. Workflow and publishing rule (via CleanupBulkTestWorkflowAndPublishingRule)
4. Test release
5. Test environment
Each step has its own try/catch with Console.WriteLine so one failed delete
does not stop the remaining cleanup.
Assert.IsFalse(string.IsNullOrEmpty(_bulkTestWorkflowUid),"Workflow UID not set. Run Test000a first.");
223
261
Assert.IsFalse(string.IsNullOrEmpty(_bulkTestWorkflowStage2Uid),"Workflow Stage 2 UID not set. Run Test000a first.");
224
262
225
263
if(string.IsNullOrEmpty(_bulkTestEnvironmentUid))
226
-
awaitEnsureBulkTestEnvironmentAsync(_stack);
264
+
EnsureBulkTestEnvironment(_stack);
227
265
Assert.IsFalse(string.IsNullOrEmpty(_bulkTestEnvironmentUid),"No environment. Run Test000c or ensure ClassInitialize ran (ensure environment failed).");
228
266
229
267
// Find existing publish rule for this workflow + stage + environment (e.g. from a previous run)
@@ -885,6 +923,84 @@ public async Task Test008_Should_Perform_Bulk_Workflow_Operations()
885
923
}
886
924
}
887
925
926
+
[TestMethod]
927
+
[DoNotParallelize]
928
+
publicvoidTest009_Should_Cleanup_Test_Resources()
929
+
{
930
+
try
931
+
{
932
+
// 1. Delete all entries created during the test run
/// Ensures an environment exists for workflow/publish rule tests: lists existing envs and uses the first, or creates "bulk_test_env" if none exist. Sets _bulkTestEnvironmentUid. Synchronous.
/// Ensures an environment exists for workflow/publish rule tests: lists existing envs and uses the first, or creates "bulk_test_env" if none exist. Sets _bulkTestEnvironmentUid.
0 commit comments