Is it possible to extend (eg. add a menu item to a context menu in) ReSharper's Unit Test Sessions window?
What I'd like to achieve is to be able to select one or more tests and then apply a custom category attribute to those tests (eg. modify the respective test's method or class to add an attribute like [NeedsFixing].
You should have a look at Victor Kropps TestToolsPlugin, which has kind of the same functionality.
Related
I'm trying to modify the backoffice refocusing functionality. Not sure exactly where the behavior is taking place but I believe the class is the FocusUtils.java (com.hybris.cockpitng.editor.util) This util class is used in the DefaultEditorAreaValidationHandler.onEvent().
The action takes place in the summary-view of a product in the "Data Quality" section. Here the user can see what fields are missing or are needing to be filled. They can click on the attribute listed and the editor will refocus on the selected field. Currently the refocusing is working with the OOTB implementation BUT it cuts off the label to the fields at times. I would like to slightly modify this util class (override) and use the custom implementation instead.
Field label is cut off
What should be dispalyed instead:
Field label is displayed correctly
The only way to do this from what I can see is by modifying/replacing the widget implementation that is using this logic. Basededitorarea widget (com\hybris\cockpitng\widgets\baseeditorarea) and specifically having to override bean definition of the below bean and additional classes as well.
<alias name="defaultEditorAreaValidationPopupDelegate" alias="editorAreaValidationPopupDelegate" />
This is the only bean I see that is defined in the backoffice-widgets-spring.xml that eventually touches this focus logic. This is like the starting point. Ideally, it would be nice to just make changes to the actual util class or replace it with a custom one rather than having to duplicate many other classes.
Does anyone know if this is the correct approach to doing this? or if anyone has any alternative suggestions that would be great.
Is there any way i can implement two stepts like this(see below) in a single function:
When I click on the "Button_name" button
When I click on the "Link_name" name
Is there any syntax so the cucumber won't care what will come after the string and on these two steps i will not need to make two different functions?
Usually i will implement them separately with something like this:
#When("^I look at the \"([^\"]*)\" button$")
public void smt (String smt){ }
Yes, you could implement one step with one method, and pass what was clicked as an argument to that method.
However, this will make your test code more complicated. So please consider whether you should. Having complicated logic in your test code, will make your tests harder to understand and maintain, thus defeating their purpose imho.
If you want to reuse common functionality, the recommendation is to write helper methods that you can call from your step definition.
For example:
#When ("I click on the {string} button")
public void clickButton(String button) {
clickButton(button);
}
#When ("I click on the "Link_name" name")
public void clickLink(String link) {
clickLink(link);
}
and implement clickButton() and clickLink() to click a button or link respectively. (I've used different clickButton() and clickLink() methods in this example, because iirc these would use different types of elements.)
If needed (or you really want to use a switch) you could use a switch statement to get use the right selector based on the button or link name.
Alternatively, you could implement page objects, add all the relevant selectors for the page object there and call the method on the relevant page object that click that particular link/button, delegating the logic to interact with the UI to the page objects and calling this logic from your step definitions.
If are different context one click button and other click link, the best practices is to have two different steps.
One of the bad practices of using BDD is to think about reusing code within steps.
When you have a lot of logic inside a step, any modification can affect many tests.
Should be concerned about code reuse in page objects.
How do you set the File Layout to put the MsTest [ClassInitialize] and [ClassCleanup] methods at the top of the file using Resharper 9?
With the default set-up for R#, the methods are just alpha sorted with the other test methods
I appreciate that I can amend the "All other members" from sort by Name, to sort first by Static and then by Name, but this seems like a quick hack
You can edit the file layout rules that ReSharper uses for reordering file content by code cleanup, by going to ReSharper → Options → Code Editing → C# → File Layout.
Full details are available in the web help, but the idea is to create a pattern very similar to the default "NUnit Test Fixtures" pattern, but for MSTest. In fact, this is a nice idea for a default pattern, so I've added a feature suggestion you can track or vote: RSRP-446275
Essentially, you want to do what the default NUnit Test Fixtures rule does.Create a new "type pattern" and add it between "NUnit Test Fixtures" and "Default Pattern". Double click to edit the pattern, and switch to constraints view by clicking the cog in the top right. Here you can say it has to be of Kind "Class" And "Has attribute" Microsoft.VisualStudio.TestTools.UnitTesting.TestClassAttribute.
Switch back to Composition (rules) view, and add an "Entry" from the Toolbox. Give it a name, such as "Setup/Teardown Methods", and double click on it. This should be set up the same as NUnit's - And (Kind=Method, Or (Has attribute=Microsoft...ClassInitializeAttribute, Has attribute=Microsoft...ClassCleanup)).
The NUnit pattern defines another couple of entries - an empty one for "All other members" and one for "Test methods", which is kind=method and has attribute=Test. Something similar could be done for mutest's TestMethod attribute.
In my Android project I've already created a custom dialog: A class named SelectColorDialog, extending Dialog, that allows the user to view a large matrix of color cells in order to select a particular color. The dialog returns the selected color value (as Integer) to the dialog initiator – typically an Activity – via a callback function.
I've a similar custom dialog, SelectTypefaceDialog, to allow easy font selection. A list of available typefaces are shown, as ListView rows, each identified by name and with an associated short sample text rendered in that typeface. The available typefaces include usual droid fonts, such as NORMAL, MONOSPACE, etc. as well as any externally sourced TTF font files that the user cares to load into a particular subdirectory on the SDCard.
These custom dialogs were not initially designed to be used directly in conjunction with SharedPreferences, preferences definition XML files or with any PreferenceActivity. Instead of, each dialog can be popped up from any activity, via the user pressing a button or via a menu item. The activity classes that create these dialogs also have internal callback classes, selection event listeners, to detect when the user selects a color or font.
These two dialogs do not have OK and Cancel buttons. Instead, the user just clicks on an item - a view of some kind - in the dialog to select the corresponding color or typeface value (implicit OK) or else presses the device’s back button to dismiss the dialog with no action taken (implicit Cancel).
I would now like to go further and incorporate these two custom dialogs into the shared preferences framework via a preferences.XML and an associated PreferenceActivity.
I would prefer to base two DialogPreference subclasses directly on these existing dialogs if possible, but I cannot see how to do so. I suspect that I cannot, and that I'll need to start all over again, and copy or adapt all the java code that is presently in the custom dialog classes – for color or font display and selection – directly into the custom DialogPreference classes instead, perhaps by overriding onCreateDialogView() and/or other methods?
This question may be a bit old, but I hope to help those, looking at the same problem in future: just extend Preference instead of DialogPreference. DialogPreference is designed badly and expected "official" way to use custom Dialog - overriding protected showDialog method does not work, because this single method contains half of class logic.
I want to add a simple panel to a dialog created using Visual Studio resource editor, but the resource editor doesn't allow this - I need to add my own CWnd as a dialog child. However that way I think I have to use CWnd::Create manually, and pass in names for the class and the window.
I want to create an ID like IDC_MYPANEL, and as much as possible add the window so it works like something defined in the template. What's the right way to do this, and what's the best MFC class to use as a simple panel... just use CWnd itself?
What do you mean by 'a simple panel'? If it's a custom control, derive from CWnd, override Create() and call CWnd::Create() with NULL as the class name so that MFC makes its own, and add a line to resource.h with the IDC_XXX value of your control. If it's a sub-dialog, with controls on it, derive from CDialog and call CDialog::Create() with the IDD that you define in your dialog.
The only difference when creating a control at runtime is that in OnInitDialog, you do some Create() and initialisation things, and you don't include a DDX_Control() line for that control. For the rest everything works the same.