How to setup testing environment for rxjs-v5? - rxjs

The official doc just give a short example for it.
https://github.com/ReactiveX/rxjs/blob/master/spec/observables/interval-spec.ts
This official testing setup to much thing.
I need a simple example so that I can start to write the unit test for my rxjs app.

Related

Hoverfly API Simulations with Golang repositories: how to get started

I have just started to experiment with Hoverfly and I have a Golang backend calling a number of 3rd party APIs for which I would need to create simulations. I am aware that Hoverfly has Java and Py bindings and I have come across a number of tutorials using Hoverfly with both. I think I am possibly missing very trivial point here, once I have created the simulations (via the Capture Mode), what is the next step? Do I simply create integration tests making use of them? Do you import the go package here into my repository? I was looking for some sample usages in the examples folder and I have seen more .py driven ones. Is there any available example that I totally missed out?
Thank you
For Golang testing, you can have a look at the functional tests in the hoverfly project: https://github.com/SpectoLabs/hoverfly/tree/master/functional-tests, it’s using hoverfly to test hoverfly!

Unit Testing with Laravel

I'm using PHP with Laravel 5.5 framework.
I recently started writing unitTests for my code and I got a few questions:
What is the best way to interact with my database?
Should I use InMemoryDB like SQLite or Mock everything with Mockery.
If I have an interaction with DB than that is still unitTesting or Integration Testing?
Thank you for the answers in advence
I work in a company where we strive for 80% code coverage, in general we test mostly End-2-End, with database and mocking external calls, we use SQLite so our testsuite can run quickly in a local environment. When the case make sense, we unit tests it, as an example an Tax service i did for different countries i unit tested, because it was very input output based.
Why we prefer End-2-End:
It's quicker if you don't have to make unit, integration and end to end testing
You test the endpoint will actually will be used
I prefer to run with a real database if you are running with Continous Integration
There is drawbacks with SQLite, mainly it does not work as other RDB where there is a lot of settings and limitations, on top of my head i had problems with foreign key enforcing etc.
So to answer your question:
It's smart to use SQLite at least locally
In Unit Testing you are only testing one class and mocking everything else, you are basically testing that the code can execute. Note this is a oversimplified version on a very complex subject.

Creating test that depends on another test case

I'm currently working on an application that uploads a file to a web service (using spring resttemplate). This upload function returns an id which can be used to download the uploaded file later on.
I want this scenario covered by a test (i'm not talking about unit test - maybe integration or functional test, whichever is appropriate).
What i want to do is the download test case will depends on the result of the upload test (since the id will comes from the upload function) - this will be tested against an actual web service for me to confirm if the upload and download functions works properly.
I'm not sure if this approach that i want to do is correct so if any one can suggest a good approach how to implement it, it would be greatly appreciated.
Thanks in advance!
Since this upload/download functionality is already covered on Unit level
I want this scenario covered by a test (i'm not talking about unit test - maybe integration or functional test, whichever is appropriate).
I know Test chaining is considered harmful
the download test case will depends on the result of the upload test (since the id will comes from the upload function)
and can cause lots of overlap between tests, so changes to one can cascade outwards and cause failures everywhere. Further more the tests should have Atomicity (isolation). But if the trade-off in your case suite you, my advice is to use it.
What you can look at, is a proper Test Fixture strategy. The other Fixture Setup patterns can help you with this.
Sounds like an 'acceptance test' is what is required. This would be basically an integration test of a subsystem for the desired feature.
Have a look at Cucumber as a good easy framework to get started.
Here you would define your steps
Given:
When:
Then:
and you can then test the feature as a whole.
Services external (that You have no control over) to Your application has to be mocked, even in e2e test.
This means that service where You are uploading file should be faked. Just setup dummy http server that is pretending to be real service.
With such fake service you can setup it's behaviour for every test, in example you can prepare file to be downloaded with given id.
Pseudo code:
// given
file = File(id, content);
fakeFileService.addFile(file);
// when
applicationRunner.downloadFile(file.id());
// then
assertThatFileWasDownloaded(file);
This is a test which checks if application can download given file.
File class is some domain object in Your application, not a system
File!
fakeFileService is instance that controls dummy file service.
applicationRunner is a wrapper around Your application that makes
it do what you want.
I recommend You to read "Growing Object-Oriented software guided by tests".

Laravel unit tests in the wild

Where would be a good place to find Laravel unit tests in the wild? Similar to this: Good Cucumber examples in the wild?
but for laravel. I know there are lots of examples out there but I’m looking for real tests based on a real project.
You could look at Laravel's own test suite, which is quite extensive and is based on PHPUnit. See https://github.com/laravel/framework/tree/master/tests.

MS unit testing azure table storage

I have been doing quite some time on Azure project and so far it’s going pretty good. Learned a lot!
Now I need to integrate a unit tester almost half way to my project (which doesn’t seem easy anymore?)
In short, I use Azure table storage to store my data for an asp.net mvc3 project (VS2010). And currently I need to test the basic CRUD ActionResults .
Can I use the free MS unit testers?
Is there any hint or clue how to so?
What you'll typically do in such a scenario is first create an interface, like ITableStorage and then create an implementation (AzureTableStorage for example) that wraps around the Azure specific stuff.
This makes it easy to replace the actual implementation with a mock/stub during your unit tests. You can take a look at the Windows Azure Helpers for an example of such an interface and a wrapper implementation: Windows Azure Helpers.
This is a good blog post about unit testing and Windows Azure: http://blogs.southworks.net/fboerr/2010/07/23/windows-azure-storage-tdd-and-mocks/
And to answer your question, yes you can use this with MSTest.

Resources