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

Add menu item to Test Explorer context menu allowing Ignore/Unignore of unit test #5064

Conversation

IvenBach
Copy link
Member

Close #2964.

TODO:

  • Create discrete separate command for Ignore/Unignore that will add/remove the annotation respectively. Following this train of thought there shouldn't be any sharing for properties, one for each (IE ExecuteToggleTestAnnotationCommand needs some love).
  • IsSelectionATest is a lie. Make it check what it's claiming.

Question:

  • Is how I've done the visibility within the XAMl for 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.

@IvenBach IvenBach added the PR-Status: WIP Pull request is work-in-progress, more commits should be expected. label Jul 24, 2019
Copy link
Member

@rubberduck203 rubberduck203 left a 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?

Rubberduck.Core/UI/Converters/BoolToVisibilityConverter.cs Outdated Show resolved Hide resolved
Rubberduck.Core/UI/UnitTesting/TestExplorerControl.xaml Outdated Show resolved Hide resolved
Rubberduck.Core/UI/UnitTesting/TestExplorerViewModel.cs Outdated Show resolved Hide resolved
Rubberduck.Core/UI/UnitTesting/TestExplorerViewModel.cs Outdated Show resolved Hide resolved
Rubberduck.Core/UI/UnitTesting/TestExplorerViewModel.cs Outdated Show resolved Hide resolved
Rubberduck.Parsing/QualifiedContext.cs Show resolved Hide resolved
Rubberduck.Core/UI/UnitTesting/TestExplorerViewModel.cs Outdated Show resolved Hide resolved
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.
@IvenBach IvenBach force-pushed the Issue2964_TestExplorerDisableTestViaContextMenu branch from 789cfa4 to 86dbaf5 Compare July 24, 2019 21:53
Copy link
Member

@rubberduck203 rubberduck203 left a 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.

Copy link
Member

@Vogel612 Vogel612 left a 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 👍

Rubberduck.Core/UI/UnitTesting/TestExplorerViewModel.cs Outdated Show resolved Hide resolved
public string UnignoreTestLabel => RubberduckUI.TestExplorer_TestToggle_Unignore;
public string IgnoreTestLabel => RubberduckUI.TestExplorer_TestToggle_Ignore;

private TestMethod _mousedOverTestMethod => ((TestMethodViewModel)SelectedItem).Method;
Copy link
Member

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 ;)

Copy link
Member Author

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.

Rubberduck.Core/UI/UnitTesting/TestExplorerViewModel.cs Outdated Show resolved Hide resolved
Copy link
Contributor

@MDoerner MDoerner left a 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.

Rubberduck.Core/UI/UnitTesting/TestExplorerViewModel.cs Outdated Show resolved Hide resolved
Rubberduck.Core/UI/UnitTesting/TestExplorerViewModel.cs Outdated Show resolved Hide resolved
Rubberduck.Core/UI/UnitTesting/TestExplorerViewModel.cs Outdated Show resolved Hide resolved
Rubberduck.Core/UI/UnitTesting/TestExplorerViewModel.cs Outdated Show resolved Hide resolved
@@ -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);
Copy link
Contributor

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.

@IvenBach
Copy link
Member Author

IvenBach commented Aug 9, 2019

Copy link
Member

@retailcoder retailcoder left a 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! 👍

@retailcoder retailcoder merged commit 35ef70e into rubberduck-vba:next Aug 15, 2019
@IvenBach IvenBach deleted the Issue2964_TestExplorerDisableTestViaContextMenu branch August 21, 2019 16:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
PR-Status: WIP Pull request is work-in-progress, more commits should be expected.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Unit Test>Test Explorer>Right Click "Disable/Enable Test"
6 participants