Skip to content
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

how to add pester result using Add-MdbcData? #14

Closed
simonfangyingzhang opened this issue Oct 17, 2017 · 4 comments
Closed

how to add pester result using Add-MdbcData? #14

simonfangyingzhang opened this issue Oct 17, 2017 · 4 comments

Comments

@simonfangyingzhang
Copy link

Hi Guru,

I want to save my test result using Pester to MongoDB,

looks like Add-MdbcData only accepts a dictionary, but test result using Pester something like 2-level PSCustomerOBject objects, how should I convert it to use Add-MdbcData?

thanks

@simonfangyingzhang simonfangyingzhang changed the title how to add pester results using Add-MdbcData? how to add pester result using Add-MdbcData? Oct 17, 2017
@simonfangyingzhang
Copy link
Author

@nightroman
Copy link
Owner

I am glad you found a way to do this. But I am still interested in the details. Why did not it work exactly? In theory, Mdbc should convert PSObject's to BSON itself.

@simonfangyingzhang
Copy link
Author

$result is returned from Pester, but $result|add-mdbcdata failed, let me know if need more info, thanks

PS C:\WINDOWS\system32> $result

TagFilter : {}
ExcludeTagFilter : {}
TestNameFilter :
TotalCount : 2
PassedCount : 1
FailedCount : 1
SkippedCount : 0
PendingCount : 0
InconclusiveCount : 0
Time : 00:00:00.3266626
TestResult : {@{ErrorRecord=; ParameterizedSuiteName=; Describe=Notepad; Parameters=System.Collections.Specialized.OrderedDictionary; Passed=True; Show=All; FailureMessage=; Time=00:00:00.2947451; Name=Exists in
Windows folder; Result=Passed; Context=; StackTrace=}, @{ErrorRecord=Expected: {false}
But was: {True}; ParameterizedSuiteName=; Describe=Notepad; Parameters=System.Collections.Specialized.OrderedDictionary; Passed=False; Show=All; FailureMessage=Expected: {false}
But was: {True}; Time=00:00:00.0319175; Name=Exists in Linux folder; Result=Failed; Context=; StackTrace=at , C:\PowerCLIinAutomationTesting\Pester.Tests.ps1: line 27
27: $Type -eq "pvscsi"|should be false}}

PS C:\WINDOWS\system32> $result|Add-MdbcData
Add-MdbcData : .NET type System.TimeSpan cannot be mapped to a BsonValue.
At line:1 char:9

  • $result|Add-MdbcData
  •     ~~~~~~~~~~~~
    
    • CategoryInfo : InvalidData: (@{TagFilter=Sys...ystem.Object[]}:PSObject) [Add-MdbcData], ArgumentException
    • FullyQualifiedErrorId : BsonValue,Mdbc.Commands.AddDataCommand

PS C:\WINDOWS\system32>

@nightroman
Copy link
Owner

Add-MdbcData : .NET type System.TimeSpan cannot be mapped to a BsonValue.

That is the reason. No, I do not need more info. All looks fine, by design, because not everything can be automatically converted to BSON.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants