for a front-end developer, who writes angular code, what part of a javascript front-end project should I be unit testing? I find it needless to test a lot of the code, and my biggest hang up is which part of the angular services needs to be tested? if $httpBackend is a mock call, what's the point of calling it?
As your project grows in complexity, you may find that your angular application is doing a lot. Angular's design allows the client to take a lot of the responsibility for processing and rendering data from the server.
Yes, I agree, you shouldn't test anything but your own code. So, writing tests for $http is useless. However, if you are expecting the server to return a specific JSON contract, and you want the assurance that you are mapping that correctly to a structure that you will use in your angular app, that is worth testing. Further, if you are making calculations in services or controllers, that logic is worth testing.
Angular itself is set up to support TDD because it has a nice separation of concerns between the view, controller and services (even directives can be compiled and tested). All of the javascript code that you write is a good candidate for test coverage. So, IMHO, you should be unit testing your directives, your controllers, and your services. You can get as detailed as you want to give yourself the assurance that your code is solid.
Related
Let's say I have a frontend application written in Angular and a backend application written in Django and Django Rest Framework. I created unit tests for backend application (with pytest) and I'm about to create some functional tests for the frontend application. The thing is that the frontend app needs access to the backend app in order to work correctly. I can write some mocks to handle that, but I am not sure if this is the best way to do that.
My question is, what is the best way to handle that? Should I use a single git repo for both applications or maybe a better way is to use two repositories, but then how to handle the tests for frontend application?
I was also thinking about using selenium with pytest, but then I would have to use a single repository. I am a little bit confused and would really use some good advice. Thanks!
Unit tests as the name suggests is testing separate units of the code in isolation. Meaning that it does not have to depend on any other part, else, you wouldn't know if the test is failing for that particular unit or the units it depends on.
As a result, all tests should mock the request to the backend and return valid responses (or invalid, if you're testing for error handling). The same applies to any other external service that the unit depends on.
This might be a broad question, but in general, why is it important to unit test in a CRUD front-end. Imagine I have a CRUD server written using Node.js, and I black-box tests for all the endpoints that the backend API offers. Having this, is there a necessity to implement some kind of unit-test in let's say an iOS client? If so what kinds of things can be tested and what should not be tested?
You could write unit tests for cases that may deal with no connectivity, bad data, internal server error (which is now thrown to you) etc
I have developed a spring mvc web application i would like to know what are the types of testing required before the spring mvc web application is live?
I have gone through different types of testing such as unit, integration, regression, functional, security, acceptance and Smoke testing
But I would like to know for a Shopping web application what are the most necessary or basic types of testing necessary before web application is live?
Is unit and Integration test enough or do I need to incorporate
regression smoke functional system testing?
Is manual testing of entire website enough for
launching a website ?
Integration Tests,Stress Tests,System Test, Security Tests User Acceptance and Manual Tests should be enough for initial launch on the internet and further as the application grows big we can go for further types of testing such as component testing,functional testing and many others for successful and robust e commerce web application deployment.But for initial startups manual testing should be given more focus and also Test Driven Development (TDD) can be followed .In TDD As the developer codes he himself writes the test cases this is to predict the results of the application but for a startup manual testing , System and Security testing must be given priority.
I recently starting learning test driven development, namely MXUnit, and I love the idea's behind it. I can understand the idea of using TDD with stand alone CFC's, but when it comes to using it with OOP based Frameworks, primarily FW/1 and CFWheels, I am not sure how to use MXUnit with the framework CFC's (controllers in FW/1 and Models and Controllers in CFWheels).
Does anyone know where I can find some resources on using MXUnit with Frameworks?
I can only talk about F/W 1 here as I have not used CFWheels (some info here in another SO question), but in my opinion framework unit testing can be simplified by proper use of a service layer.
The idea is you test service layer objects using MXUnit and leave the framework controllers (for example in FW/1) very lightweight. Essentially the controllers are just passing parameters to the service layer, getting a response back and displaying a view.
The reasoning is that the framework is the least likely place you'll introduce errors - so concentrate your testing on the service object, i.e. the core business logic of your application.
Interestingly, in other non-ColdFusion frameworks (such as Grails) the framework is not tested, tests are created for your model ('domain classes' in grails that model the data) and your service objects, but the framework is assumed to work fine. The idea there - again - is to keep logic out of your controllers and test your service layer and domain model.
I hope that helps in some way.
I'm developing a web app with MVC 2.0. I'm storing my data in Windows Azure table storage. I'm not using any mocking for my test. The test framework is the default Microsoft Unit Testing that comes with Visual Studio.
At the moment, I'm only testing my controllers: the view names that are returned, the flow when the code jumps from action to action and the view models that are sometimes returned sent to the views.
My approach isn't TDD: I write a bit of code and then I test it to make sure it passes. I'm just unit testing, not driving my development by testing first.
Am I doing the right thing with my testing: is it enough to just test the controllers?
In terms of what you should be testing, I recommend testing anything that has a branch statement and complex statements. What do I mean by that? You should be testing any code with if/else or switch statement as well as any mathematic calculations, regex, etc. For your application, this may just be your controllers, but may include views, models or any other classes that you have written. Its not uncommon for view models or domain models to contain code that should be tested.