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
Add menu item to Test Explorer context menu allowing Ignore/Unignore of unit test #5064
Add menu item to Test Explorer context menu allowing Ignore/Unignore of unit test #5064
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There are multiple ways to handle visibility. If we’re going to use two separate VM props for the different menu items, and just toggle visibility, I would stick to the way you did it.
Alternatively, there could be a single menu item whose text and command get bound to single VM props. I personally think either is a fine solution.
Where are the tests for the new code though?
Context menu for TestExplorer has a command enabled for Ignoring/Unignore that will add/remove the annotation.
Replaced conditional property that would change with explicit properties. Forgot to remove when `UnignoreTestLabel` and `IgnoreTestLabel` replaced it.
789cfa4
to
86dbaf5
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The only thing that I really want to be changed is the Binding vs Resx thing, everything else is optional :) Looks very good 👍
public string UnignoreTestLabel => RubberduckUI.TestExplorer_TestToggle_Unignore; | ||
public string IgnoreTestLabel => RubberduckUI.TestExplorer_TestToggle_Ignore; | ||
|
||
private TestMethod _mousedOverTestMethod => ((TestMethodViewModel)SelectedItem).Method; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if we check for SelectedItem
being null, this shouldn't assume it is not. The reason for that is that we can't ensure this is only evaluated in Display(Uni|I)gnoreTestLabel
. It might be easier to have something like SelectedItemIgnoreMatches(bool ignoreState) => (((TestMethodViewModel)SelectedItem)?.Method.IsIgnored ?? !ignoreState) == ignoreState;
. This is a bit... dense, though, so a proper method would probably be best ;)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll need more breadcrumbs to follow and understand this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wonder whether it would make sense to have some toggle ToggleIgnoreTestCommand
to be property injected into the view model. However, that might complicate things a little.
Anyway, I would suggest to actually do DI all the way and inject the IAnnotationUpdater
.
@@ -14,7 +14,7 @@ public MockedTestExplorer(MockedTestExplorerModel model) | |||
Vbe = model.Engine.Vbe.Object; | |||
State = model.Engine.ParserState; | |||
Model = model.Model; | |||
ViewModel = new TestExplorerViewModel(null, Model, ClipboardWriter.Object, null, null); | |||
ViewModel = new TestExplorerViewModel(null, Model, ClipboardWriter.Object, null, null, null, null); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As a general rule, we should avoid newing things in tests but rather reference to a single static method Arranage...
. That helps us avoid having a ugly refactoring session when we need to modify the parameters for the ctor. This puppy is already up to 7 parameters 😨 so it's surely itching to be refactored.
https://github.com/IvenBach/Rubberduck/blob/Issue2964_TestExplorerDisableTestViaContextMenu/Rubberduck.Core/UI/UnitTesting/TestExplorerControl.xaml#L421 for not-so-distant-future-Iven to attempt to add |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Excellent work, keep 'em coming! 👍
Close #2964.
TODO:
ExecuteToggleTestAnnotationCommand
needs some love).IsSelectionATest
is a lie. Make it check what it's claiming.Question:
TestExplorerControl
appropriate? I thought about having it be a property on the VM but that didn't feel right when I was trying to code it up.