-
Notifications
You must be signed in to change notification settings - Fork 195
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
Potential issue with unit tests and cloned PnPContext #591
Comments
@s-KaiNet : the cloning was not well handled when it comes to offline test file generation, things could go wrong especially when using multiple clones or when using cloning inside tested methods. The reason for this is that the logic applied to come up with a unique id for the response file was flawed and sometimes generated the same response file name, so the last one overwrote the first one. When testing online all works, but when offline the wrong response file was picked up resulting in errors. I've just pushed a fix for this: c02e124. I've also added your test case to our set of tests: https://github.com/pnp/pnpcore/blob/dev/src/sdk/PnP.Core.Test/Base/PnPContextTests.cs#L695-L715 Thanks for reporting this, this will make it easier to write test cases. |
Thanks! I hit that issue when working with AppManager, because for some operations I have to switch context to the tenant app catalog using Clone. As a result under certain conditions, some of the tests didn't work in Offline mode. |
@s-KaiNet : if the updates worked for you then feel free to close this issue, if not then let's try to get things fixed. |
Yes, it works perfectly, thank you! |
Category
Describe the bug
I found an inconsistency when running tests in Online and Offline mode.
Below test passes in Online mode and fails in Offline.
I was able to narrow down the problem to the way how recorded
.response
files are created. The pattern is[method]-[test id]-[step]
. The problem happens here:The very first context will have the
TestId = 0
, next cloned contextctx2
will beTestId = 100
, however, the third one also will beTestId = 100
, because it's based on the same original context withId = 0
. As a result, the latter context will overwrite all.response
files created by thectx2
. Simply because it has the sameTestId
and generates the same.response
file path.Steps to reproduce
Just run the above test method in Online and then Offline mode.
Expected behavior
I expected that in the case above the test should pass for both modes. However, I'm not sure how to properly fix it, because it looks like the problem is inside the tests infrastructure core.
The text was updated successfully, but these errors were encountered: