Skip to content
Discussion options

You must be logged in to vote

I have tried using the StateBag of the previous method, but this does not work since it just gets the StateBag of a previous test method that has executed last.

Not sure I quite follow? If you store data in the Create State bag, your modify tests should be able to use that.

Calling TestContext.GetTests(...) should give you an array of tests, so all of those repeats. The order of these won't be deterministic, so I would probably try to get an Id from the bag and remove it so another test can't see it.

I'd iterate through each of them and try something like:

foreach (var test in tests)
if (test.StateBag.Items.TryRemove("key", out var id)) { ... }

The TryRemove should remove it from the d…

Replies: 3 comments 1 reply

Comment options

You must be logged in to vote
0 replies
Answer selected by Casimodo72
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
1 reply
@thomhurst
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants