How do you filter the display of traits in Visual Studio Test Explorer? - unit-testing

I'm using Visual Studio's Test Explorer with Machine.Specifications and would like to organize the tests by the Subject attribute. When organizing tests by trait, all the tests are grouped by Subject, but they are ALSO listed under the ClassName trait. That is to say, all tests with a Subject attribute will be displayed twice: once under the ClassName trait and once under the Subject trait. I would like to only display the Subject traits.
The search filter appears to allow you to show/hide tests which have a given filter (e.g. Search: Trait:"Subject", or -Trait:"Subject"), but it doesn't seem to be possible to only view tests under a specific trait. Is this possible?

Related

How do I set model variables within an acceptance test?

In Ember.js, I currently want to test a UI feature present. Essentially, once a model variable changes, I expect to see a UI element appear (a checkmark). I have tried creating a model within the acceptance test but this unfortunately did not work as I did.
I just wanted to know which function to use to set model variables.
A model typically would involve unit tests, but like you've said you're testing the visual result of something being set on a model. I would recommend an integration test. If you are able to refactor (or maybe this is the case already), the part of the template into a component then you can create an ember test for the component and pass in the model set up perfectly how you would like.
If this test really does depend on the model being setup a specific way I would look at how your application sets up that model to begin with and try to replicate those actions with click and fillIn helpers. Another way is say, your application wants to setup a user but relies on a network request to do this, then you could use pretender.js and fake the response to that request so that the application's inputs are setup from the network in the way you're after.
I would really try to do this an acceptance test though, the composable nature of components allows them to be tested in stricter isolation, these tests will run faster, and you're worrying less about side effects.

Enterprise Architect document template conditions like `if` and `elseĀ“

I'm working on my first Enterprise Architect custom document template to export our use cases considering the company design guidelines. Unfortunately, I am not able to print data based on certain conditions. E. g. hide fields with specific values or change their layout.
In my example or screenshot below I would like to hide {ElemScenario.Type} if the value is Basic Path, in example something like (I highlighted the position red):
if ({ElemScenario.Type} != "Basic Path") {
{ElemScenario.Type}
}
How can I change the document template in Enterprise Architect with certain conditions? Is it even possible?
You filter the content in the document options.
If you need only one type of scenario then you can do that in your main template, but you'll probably want to make three separate template fragments, each showing only one specific type of scenario.
See also my article Tutorial: Generate complex documents from Enterprise Architect with a two-step semi-automated approach for a complete example of a use case template.

Multi-variate testing with custom form component

I have a custom form component that captures lead information and then gives the visitor a download. I have set up an A/B test on the form with different fields and layout to determine which form is the most effective at capturing leads. Basically our A case is the full form and the B case has only the required fields.
Until now both our A and B cases have a score of 0. How do I measure success for a case of the multivariate test? I imagine I need to trigger something in the code-behind that indicates a success or complete state but I don't have anything to go on. What am I missing either in the Page Editor/CMS side or on the code side? Or is this even possible?
Sitecore CMS 6.5.0 and DMS 2.0.0 rev.111230 (6.5.0 Update-3) - Not using WFM
Sounds like you might not have 'deployed' your test? You need to go into the Marketing Center > Test Lab > find your test and then in the Review Tab there will be a 'Deploy' option.
When you're done with your test, you come back here and click 'End Test' in the same place.
Check out the marketing operations cookbook for more detail.
http://sdn.sitecore.net/upload/sitecore6/65/marketing_operations_cookbook_sc65-usletter.pdf

Can I insert a Component TEMPLATE Link in the Tridion GUI?

In Tridion, similar to how a field in a schema or metadata schema can either be text, embedded schema, or component link... is there a way to allow the field to be an item select like a component link, but select different types of Tridion objects instead of components?
I'd like the user to be able to select a Compound Component Template or a Page object via selecting it through the interface instead of typing in the tcm into a text field and reading that value.
Is this possible?
No. Links to Component Templates are not handled by the Tridion GUIs. The Tridion Content Manager back-end can handle links to Component Templates in some situations, which is why (for example) you can see the Component Templates show up in the WhereUsed dialog of a Page.
Most people end up using a regular text field for holding such a Component Template link and then use something like Bart's Item Selector to provide an input aid.
You must be careful by creating links to other types than components because they might not be content portable and you will get issues after porting those fields from one environment to another.
Basically the tcm uris won't be resolved by content porter.
This would have to be achieved by building a custom CME (GUI) extension.

Unit testing MVC3 Razor helpers/views without strings

I am trying out the MVC3 Razor view engine, and one the features that I am exploring is the ability to unit test views.
I have seen a number of examples where Razor views can be compiled into an assembly and rendered into a string. The problem is that it renders as a string, so I am left with doing string searches!
Here is what I am trying to do.
Create a Razor helper
Compile helper
Run compiled helper, passing in a ViewModel
Get the output of the helper as some sort of HTML/XML/tree structure
The reason that I want to do this is so that I can test for specific parts of the output. The helper will likely spit out HTML that includes various output gunk. What I want to do is to see if there is a Checkbox with a particular value (for example). If you have seen Selenium tests, it is similar to what I would like to do, except not as server driven tests.
Is there some way to get compiled Razor (or other view engine) views to emit something other than strings?
The short answer is no, because view engines' purpose in life is to spit out strings. Parsing those strings into an XML document is a way to give them a little structure, like #Craig-M suggested. But what you have to ask yourself is what you're really testing. If your view compiles and generates some kind of HTML, there can be three problems with what it generated:
the data it displays is not correct. You would test for this at the controller level, so you can ignore it during view testing.
the MVC framework had an error and it generated the wrong HTML string. You don't worry about this, because MVC has its own test suite and thanks to separation of concerns, it's not your problem.
the HTML has broken the user interface.
That last one would be very nice to test for, but why not test for it in javascript unit tests? Check out popular javascript unit test suites like JsUnit, FireUnit, QUnit, etc. They would all do a much better job than you could do of parsing out Razor output.
I think the value assigned to a checkbox would probably be tested for in Controller testing. But to use your example, testing your checkbox's value could be $('#theCheck').val() == 'the value'. And you can run these against a website running with dependency injected repositories or services to control things like 'the value'.
Just a thought.
One way you could go about this is to parse the html string into an XDocument and have your assembly return it. Then you can query against it with LINQ in your tests.
Edit: I'm trying to figure out a Razor test strategy too. I'd be interested to know how you get the helper to work. So far, I'm drawing a blank in getting them rendered to strings outside of the MVC framework.
How about rendering your views to html and then sending that html to HtmlAgility library? That way you can easily traverse/navigate your html. I don't think there is any way to do that with MVC itself.
It looks like Microsoft has its own answer of how to produce HTML from views, for the purpose of unit testing.