Does any one have experience utilizing ready frameworks as specflow with CQRS in BDD.
I liked the approach of Mark Nijhof, however I have already been using SpecFlow for other projects. Can anyone offer a bit of enlightenment, with an example if possible?
I am using it in my current project.
I am using SpecFlow for UI testing (Web client) and for some import tests.
For unit testing, I am using Machine.Specifications.
I think SpecFlow suits the task well. I have support from the requirements expert, the sprint tester and sometimes the project manager in writing specifications which means that I can concentrate on implementing features instead of reading through heavy requirements specifications.
Technically I use CassiniWebDev to host the web client project and simple Process.Start for the NServiceBus endpoints for tests that use the full circle. I use Selenium for the web UI tests and FluentAutomation on top of that. It took a couple of days to set it all up, but it's definitely worth it.
I generate SpecFlow reports, use Pickles to render Features to web and take screen shots with Selenium and publish the entire thing on the project website so that all the stakeholders can see what's going on and what things look like at the moment.
I'd recommend SpecFlow for a BDD/CQRS project.
I have used Machine.Spec for testing CQRS with BDD. From my point of view it worked quite well. For example:
Establish context = () =>
{
// set up your fakes & mocks here...
};
Because of = () =>
{
_bus.Send(_createNewCustomer);
_version++;
};
It should_create_a_customer = () =>
{
_repository.GetById(_id).Id.ShouldEqual(_id);
};
It should_publish_a_customer_Created_event = () =>
{
_subscriber.HandledEvents.Count.ShouldEqual(1);
_subscriber.HandledEvents.First().Value.ShouldBeOfType(typeof(CustomerCreatedEvent));
};
Cleanup Clear_Context = () => _subscriber.HandledEvents.Clear();
Related
I am very new to electron, trying to use it to build a cross-platform app which should be able to run natively on the machines. On the server side, I already have an application which exposes a REST API, documented with swagger.
Now I am trying to generate a client stub for this swagger definition, which I can then use with electron. How is that accomplished? Should I just generate JS code and use it (how would that work?)? Or is there another (better) way to do it as Electron has build in functions to access REST APIs like
I spent a considerable amount if time searching for a solution and did not find one. Now I wonder if that is such an uncommon scenario to use Electron as framework accessing REST APIs, and auto-generating the code using swagger codegen.
The great thing is that Electron apps can be very similarly developed to normal web applications. This is possibly why you didn't find specific instructions for using Electron with the tools you are used to using.
You should be able to go ahead and use whichever tools you would normally use to generate stubs for calling REST from any web application, and the stubs should work fine when referenced within Electron (as long as they generate in Javascript or Typescript).
Have you tried using Swagger codegen, did you try use the resulting client code API, and did it give you an error? Try posting any specific errors as new questions on Stack Overflow for solutions (or edit this question to be more specific).
Electron is almost like a blank canvas - there is no "right" or "wrong" way to develop, although there are certainly "good practises" and "bad practises".
There are definitely concepts that are unique to developing applications within Electron and for this it would be good to couple your development experience with some general Electron reading and learning.
You will very soon run in to "unique" Electron concepts such as "main" and "renderer" and it will be much easier if you have learning material to guide you. There is a lot of material for learning Electron so I won't try make a list here.
Also note that Stack Overflow is more useful when specific errors or minimum examples are provided and you'll probably get better answers that way :-) See: https://stackoverflow.com/help/mcve for more info on this.
I actually ended up swagger-codegen as GrahamMc suggested.
The general approach was like that:
rm -rf api
wget http://localhost/site/json-schema -O api.json
docker run --user `id -u`:`id -g` --rm -v ${PWD}:/local swaggerapi/swagger-codegen-cli generate -i /local/api.json -l javascript -o /local/api
rm api.json
cd api
npm install
Step 1 is cleaning up old generated code and step 2 is downloading the swagger spec which is not available from within the docker-container. The rest is cleaning up and installing dependencies.
From within the code, it can then be used like that:
var jtm_api = require('.api/')
var userApi = new jtm_api.UserApi()
var cb = function(error, data, response) {
if (response.status == 200) {
//do whatever
} else {
//do whatever
}
}
userApi.usersLoginPost(txtUser, txtPwd, cb)
There is an extensive documentation available on how to use the generated code starting from the README.md file within the generated folder.
I would like to use Zebble only for producing UI and all other things I would like to use Xamarin apis/custom http apis/local db or whatever it may be. Basically a UI project with zebble and other things will be in PCLs.
Will it be compatible? Could you please advice?
Yes you can. There is nothing in Zebble that prevents you from using the native APIs directly.
For custom http calls, I recommend using the HttpClient class which is by default available in all 3 platforms of a newly created Zebble project.
For Device APIs, you can of course use the standard API classes of each platform, but to save time and achieve 100% code reuse I strongly recommend using the http://zebble.net/docs/device-api. For example if you want o use the lamp (aka flash, led or torch) you can very easily implement that on all platforms with very little code code:
// Determines if a lamp feature is available on the device.
if (await Device.Torch.IsAvailable()) { ... }
// This will switch the lamp on.
await Device.Torch.TurnOn();
// This will switch the lamp off.
await Device.Torch.TurnOff();
I'm trying PHPStorm and have trouble with its code completion. I write project with Silex framework and faced PHPStorm's lack of code completion for Silex dependency injection container. For example, it doesnt codecomplete $app['twig']-> or $app['db']-> or any other service. The only way solution I've found is to do smth like this
$db = $app['db'];
/** #var $db \Doctrine\DBAL\Connection */
$db->....
And then PHPStorm will do code completion. Services are registered using ServiceProvider interface.
Is there a way to make PHPStorm do code completion in such cases without additional vars and comments?
As far as I'm aware, this is currently not possible, however, there is currently work going on to add support for generic factory patterns, see this issue on their issue-tracker:
http://youtrack.jetbrains.com/issue/WI-6027
The PhpStorm developers welcome new feature requests on their issue tracker and are quite responsive. So you may file a feature request
Also, this may be related to your question:
http://youtrack.jetbrains.com/issue/WI-5304
Here's a plugin for PHPStorm / Intellij IDEA:
https://plugins.jetbrains.com/plugin/7809?pr=
Didn't tried it yet, but looks promising...
Edit: Just gave it a quick shot, and it looks really cool and simple to set up:
Install the plugin via the IDE plugin manager
Add the following dependency:
"require": {
"sorien/silex-pimple-dumper": "~1.0"
}
Register the provider:
$app->register(new Sorien\Provider\PimpleDumpProvider());
And you are done.
Greetings,
I am interested in adding test coverage for an existing application. The technologies involved include EJB 3.0, jboss 5.1, Hibernate and MySQL. This project is built using Ant. The goal is to provide test coverage to this application to allow further features to be added with confidence.
Initial searches give several ideas, but I have yet to find an tutorial or a start to finish set up steps to create an initial unit test.
I found EJB3Unit to be promising.
http://ejb3unit.sourceforge.net/Installation.html
However, the examples to setup are for maven and we are using Ant.
If anyone could help with how to setup a simple example test with EJB3Unit and Ant it would be very helpful.
Thanks for your time,
Conor
You will have to ask yourself "What exactly am I trying to test?" first.
If you want to test your EJB3 in isolation, remember that an EJB3 is just a POJO. You can call the class directly from a jUnit test method.
If you want to test your EJB, the Application server, the Container, AND your network (if #Remote annotation is used) then you can write an integration test class that looks up the #Remote or #Local EJB in the JNDI tree of your container like so:
#Test
public void callEjb() throws Exception {
Context context = new InitialContext();
YOUR_EJB_CLASS myEjb = (YOUR_EJB_CLASS) context
.lookup(JNDI_PATH_FOR_YOUR_EJB);
myEjb.myMethod();
}
If you want to test your EJB as an EJB and separate from an EJB Container, then EJB3 could be what you are looking for instead.
P.S. Don't let Maven scare you. I haven't used it yet, but it seems that it is gaining in mind-share over ant.
I'm investigating Grails vs. other Agile web frameworks, and one key use case I'm trying to support is the ability to modify controllers and install plugins post deployment. It appears that this isn't possible with Grails, but I want to make sure before I write it off.
As far as modifying controllers goes, it would be sufficient if the Groovlet behavior existed (compile-on-demand).
As far as plugin installs go, I understand this may be a long shot, but I thought I'd check to be sure.
For your information, I need this because I work on a product that requires a little site-specific customization, such as adding validation of simple meta-data, integrating with customer security environments, and maybe even including new controllers/pages quickly.
Out of the box, no, grails doesn't really support what you want. There may be ways to customize it but I've never looked into it. A PHP framework might be more of your ally since there is no real deployment process other than copying PHP files to a location.
That said, I personally would prefer a strict set of deployment policies. And honestly, deploying changes with Grails is as simple as running the 'grails war' command and copying that war to your servlet container. The site's downtime is negligible and if you have multiple web servers with a load-balancer, your customers should never see down time due to deployments.
Although it's not recommended for complex coding; You could execute groovy code from a string that you could store in database or a file on the fly at run time:
check out Groovy template engine:
http://groovy.codehaus.org/Groovy+Templates
but even then, you are still limited on what you can do or can't do let alone debugging will lack. you may want to consider an interpreted language; few to mention PHP/Perl/Coldfusion.