In FitNesse is it possible to override settings configured in the root page? - fitnesse

The root page in FitNesse is a great place to add configuration which can be used by every page. Things like defining the test system or test runner. Is there any way of overriding those settings, though, for a single test page or for a test suite?
I have a project using FitSharp (FitNesse for .NET) and have the appropriate settings in the root page. Now I want to include a test suite that uses a Java fixture. So, for that suite I want to override the command pattern and test runner defined in the root page.
As far as I can see, settings defined in a root page or in a higher-level suite page are not overridden when I redefine them in a lower level suite page. Is there any way of getting around this or will I have to redefine the appropriate settings in every suite - FitSharp settings in each of the .NET suites and Java settings in the Java suites?

You can nest suites inside suites, so you can have two top-level 'container' suites, one for all .NET suites and one for all Java suites. Define your settings in these 'container' suites, not the root.

Related

Multi-Module Vaadin project where routed views are located in independent modules

I'm playing around the idea of a very huge vaadin application, which consists of a skeleton (providing the ui framework) and hundreds of functional units (providing the specific vaadin views).
The main architectural point is to let the skeleton be agnostic about the functional units, so not a single java dependency to a functional unit should be injected into skeleton. Every single functional unit has to be in it's own distinct JAR.
The vaadin container is started by the skeleton-module. It is perfectly possible to build a navigation with all the necessary routes to the functional units (/routeToView001.../routeToView999) without having further details about them.
However, I don't see, how the started vaadin spring boot container would load the java classes from the independent JARs when navigation occurs in browser. Practical attempts failed. Any ideas?
The Spring Boot integration is by default looking for #Route classes within the Java package that contains the #SpringBootApplication class. This can be further configured by passing package names to the #EnableVaadin annotation.
I haven't tested this in practice, but it might be possible to have a multiple #EnableVaadin annotations so that there would be one in each module and through that also provide multiple locations to look for #Route classes from. In that case, the #EnableVaadin class in each module would also have to register itself in the same way as any other #Configuration by using the regular Spring Boot autoconfiguration mechanism.
Another alternative is that you register route classes manually to the application's route registry (accessed using ApplicationRouteRegistry.getInstance(new VaadinServletContext(servletContext))). In that case, you might still need to have at least a dummy #Route in the base module since Vaadin might not automatically enable itself in a Spring Boot environment unless at least one #Route class is discovered in the regular way.

Can I test an ASP.NET MVC web project using Selenium from a unit test project in the same solution?

I have an ASP.NET MVC 5 web project, and I have an MsTest-based unit test project that uses Selenium to do some automated "browser" tests.
Currently, I have to run the web project (in my local IIS Express) and then run the tests against that, but that has all kinds of restrictions. For example, I can only "run" the tests, I can't "debug" them. And clearly this doesn't play well with my continuous integration pipeline.
Is there no way to have the tests spin up an instance of the website? (I know that ASP.NET MVC 6 can be self-hosted, so that might open up some possibilities, but this project will be stuck on MVC 5).
OK, here's a way to do it:
Spin up a web server in a method decorated with the [AssemblyInitialize] attribute (this method must be in a class in your test project decorated with the [TestClass] attribute).
[AssemblyInitialize]
public Initialize()
{
...
}
Stop the web server in a method decorated with the [AssemblyCleanup] attribute.
[AssemblyCleanup]
public Cleanup()
{
...
}
To start IIS Express you can just use Process.Start on IISExpress.exe, passing in the path and port arguments. (To stop it, you can simply kill the process you started). See the link in Fran's answer for an example.
The path argument should point to the folder containing your website project (the project folder, not the bin folder).
The port argument needs to be the same local port number used when you run the website locally (so if the URL in the browser window is http://localhost:57941 then the port number you need is 57941).
I'm not sure how you'd do this with just Selenium. Selenium is just automating browser processes. you might be able to write a script or you could use a testing framework like SpecFlow to start up a webserver before your test run.
http://www.radicalgeek.co.uk/Post/12/starting-up-iis-express-for-a-specflow-and-selenium-webdriver-test-run
Archived link in case the first one does not work: https://web.archive.org/web/20160927003518/http://www.radicalgeek.co.uk/Post/12/starting-up-iis-express-for-a-specflow-and-selenium-webdriver-test-run

Property injection on attributes not working from a unit test

During execution as an Asp.Net Mvc application, property injection by autofac works successfully, as documented here:
http://code.google.com/p/autofac/wiki/Mvc3Integration#Filter_Attribute_Property_Injection
If I carry this same logic through to a (nunit) unit test, the properties are not being injected on my custom attribute. Is there something specific in the mvc extensions that would cause this not to work from a unit test?
Thanks
Filter attribute property injection works as part of the MVC/ASP.NET pipeline, not as something available as a standalone feature.
You'll probably notice that the filters on an MVC controller don't actually execute during unit tests either. For example, put the HandleErrorAttribute on your controller action and throw an exception from that action in a unit test. Notice how the HandleErrorAttribute didn't get invoked to try to send you to the error view?
This is because in a unit test scenario, you're not in the MVC pipeline - you're testing controllers/actions as POCO (Plain Old CLR Objects). You won't get model binding, filters, HttpModules, or anything else that you'd normally see as part of real integration/execution.
That's not an error, that's by design. It's similar to the way you can unit test WCF service implementations and if you attach behaviors to them via your web.config you won't see those behaviors in the unit test. Your unit test isn't executing in the pipeline, it's executing only against the one class as a standalone entity.
If you need to test how the whole thing works together with filters and all - an integration test - you'll need to look into retrieving the content from a running version of your web application using browser automation or some other programmatic web client mechanism. For the pipeline to be in place, you have to actually be running in a real, full runtime, not in a standard/standalone unit test environment.
As far as whether it's OK to use DI in unit tests or not... that's more a personal preference. I use it in some of my tests, but when I do, I wire up mocks/stubs as the dependencies so I can control the interaction between my system under test and its dependencies. You don't need DI to do that. You could just construct all the fake dependencies manually and poke them in without any DI/IoC container at all. That said, in a unit test environment, you shouldn't be wiring up The Real Dependencies because then you're not testing your class as a unit - that's an integration test.
You should avoid using DI for unit testing. Unit testing is all about testing the functionalities of the a particular piece of code and not others. In your case if you are testing the custom attribute then you should set the dependencies directly without relying on any IoC container to do that.
Most of the cases the dependencies would be replaced by mock objects instead of the real ones.

Open Discussion - Symfony - what do you do to start your projects quicker?

When you start a new project (whether it's personal or professional) what do you have at hand to quickly start developing the project?
For example, when I start a new project at work, I have the following already setup from a custom sandbox:
Two different authentication classes, LDAP and CAS which I can change via app.yml
Custom form widgets which I use across most applications
Capistrano deployment script for deploying the project to staging or production servers.
A mail template class which uses an XML file for the templates to send emails
Mail server, ldap etc. settings all configured.
Bunch of icons and the same CSS (which with some exceptions is always the same for each project)
custom error pages, layouts, login layout etc.
static pages such as about, contact us etc.
Useful plugins such as sfFormExtraPlugin, twig etc.
jquery and jQuery UI libraries
Basic local ACL and translation model classes and some other default models.
Tasks - send email task and build translations.
custom tools class for doing some custom stuff
custom factories and some default routes
helpers which I will most probably use are enabled by default (i18n, partial etc.)
And some other things :-)
I'm just wondering what you do to make your development quicker and more efficient when starting a new project. Hopefully I'll learn some new things from what you do.
Thanks folks!
Great question and great list. Here's some more:
As a general practice, whenever we develop a feature that could be used across projects, we develop it as a plugin so it can be easily dropped into other projects.
Custom form formatter that uses our own widget/validators in place of the default Symfony ones.
Custom mailer with support for sending processing templates as emails and better HTML email support.
Plugin for minimizing/combining CSS and JS assets.
Symlink from web/sf to lib/vendor/symfony/data/web. Better than an alias in apache.
Custom admin generator templates.
Quick setup script that takes commandline options or read a config file to create full local dev env (init the project, setup a vhost, modify etc/hosts, import to svn, create svn externals for Symfony and key plugins like sfDoctrineGuard)
Custom Project skeleton
Custom Javascript helper based on Apostrophes new a_js_*() helper functions

Fitnesse - Can I make an existing wiki page a subwiki?

I am trying to create a test suite of some of the existing pages I have developed using fitnesse. Does the tool support to change or refactor the pages to sub-wikis to make a part of newly created test suite?
Not sure if I understand your question exactly.
You can refactor a test suite to be "reparented" to another wiki. Just go to the page and select the "refactor" button. In the text box, select the new parent page path in the form of "MyWiki.MySubPage.EtcEtc".
You can use symbolic links for that.
Click Properties on the sidebar, then at the bottom you can symlink your pages from other suites into the suite.
This feature can be used also to run tests with different setup/teardown variations.

Resources