diff --git a/docs/docs/test-authoring/depends-on.md b/docs/docs/test-authoring/depends-on.md index aa59ac5319..c192670fcb 100644 --- a/docs/docs/test-authoring/depends-on.md +++ b/docs/docs/test-authoring/depends-on.md @@ -101,9 +101,9 @@ public async Task AssertItemsInDatabase() ``` ## Getting other tests -If your tests depends on another test, it's possible to retrieve that test's context. This allows you to do things like check its result, or retrieve objects from its object bag. +If your tests depends on another test, it's possible to retrieve that test's context. This allows you to do things like check its result, or retrieve objects from its state bag. -This is done by calling the `GetTests` method on a `TestContext` object. It takes the test's method name (so you can use `nameof(...)`) and optionally the parameter types for if there's multiple overloads. +This is done by calling the `GetTests` method on the `TestContext.Dependencies` property. It takes the test's method name (so you can use `nameof(...)`) and optionally the parameter types for if there's multiple overloads. You'll notice this returns an array - This is because tests may be data driven and be invoked multiple times - If this is the case you'll have to find the one you want yourself. @@ -119,15 +119,15 @@ Example: public async Task AddItemToBag() { var itemId = await AddToBag(); - TestContext.Current!.StateBag.Add("ItemId", itemId); + TestContext.Current!.StateBag.Items["ItemId"] = itemId; } [Test] [DependsOn(nameof(AddItemToBag))] public async Task DeleteItemFromBag() { - var addToBagTestContext = TestContext.Current!.GetTests(nameof(AddItemToBag)).First(); - var itemId = addToBagTestContext.StateBag["ItemId"]; + var addToBagTestContext = TestContext.Current!.Dependencies.GetTests(nameof(AddItemToBag)).First(); + var itemId = addToBagTestContext.StateBag.Items["ItemId"]; await DeleteFromBag(itemId); } ```