Best way for a test to reference which function it is testing? #1984
Replies: 2 comments 7 replies
-
Related, if it was possible to get test results emitted as they complete as output objects I could make the test runner more responsive by updating the UI as the tests complete rather than waiting till the end. I suppose I could grok the text output but having a structured method would be much better. A pesterconfig output option that would be something like "objectsonly" that would return individual test objects as they complete and then the full output at the end. |
Beta Was this translation helpful? Give feedback.
-
There is long time proposal from Gael to have metadata on tests. I recommended he tries using single item -ForEach. There you can specify any data, even data you don't use in your test. He told me that he will try it, but got no feedback. All these data are then on .Data on the result object. So I would recommend you start with that as well, before we try adding something like .Metadata. |
Beta Was this translation helpful? Give feedback.
-
So I've been playing with the new vscode proposed test api, and one neat thing about their markdown example is that the tests can get a codelens right next to the actual code, not just where the test exists, which is nice not having to bounce back and forth, especially when using the autorun.
This got me thinking, maybe there should be a way for a test to reference what function it is testing (which would be completely optional). As a simple test I just used the describe block to match to the function name using an AST parser.
Should there maybe be an explicit parameter for describe/function/it blocks (e.g. "-For" to reference it is for a particular function) to codify this? It would just be an additional property on the block objects, nothing that pester would initially use directly except maybe to say Invoke-Pester -For 'Get-MyFunction').
@nohwnd thoughts?
Beta Was this translation helpful? Give feedback.
All reactions