Code Quality and Unit Testing for a Landing Page - unit-testing

I'm creating a personal portfolio landing page using react. This is just a simple landing page with static content so far.
Lately, I have been writing unit tests to my code on other projects, so I wonder, is there any way to make unit tests to this kind of website? Or is there no reason at all to do this?
Is there any other kind of test that I can make to check the stability and quality of my code?

Related

in angular web application what needs to be unit tested?

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.

BDD when testing a web service / API

I am still trying to totally understand BDD and I am facing some doubts.
From my little experience, I have been using it to automate user acceptance test and I would like to know if it's possible to use it to test a web API, without UI.
In the past I've used BDD using the given-when-then jargon and mapping the steps to UI interactions. I've done this with Specflow in ASP.NET or cucumber/capybara in ruby on rails.
So for example we could have scenarios like this:
Given I am in the home page
When I click login button
Then I should see the login page
The current project I am working at is different. We are implementing an API based in web service which would be consumed by different type of clients. Like an iphone app, android app and an asp based web client. So our main focus is based in the back-end and just that.
In this case, the tests can't be faced from the UI point of view. So our end-to-end tests are based in our service endpoints. We pass some input arguments to a service calls and check the outputs.
Can we do this using BDD? Is this right?
or maybe it would be better to use a different thing like FitNesse?
Hmm.. is using FitNesse doing BDD?
I think you can do what your writing about in BDD. I'm not sure if those 2 links about testing of webservices with SpecFlow will help you but take a look on them if you haven't seen it yet.
http://codedetective.blogspot.co.uk/2012/10/testing-webservices-with-specflow.html
http://www.creamdog.se/blog/2011/02/24/webservices-automated-tests-using-specflow-and-babelfish/
Have a look at Karate, web service testing framework by Intuit. It's recently being open sourced. It has the capability of handling API dealing with HTML, JSON, XML, GraphQL queries and is built on top on cucumber.
Simple intro here : https://medium.com/blueprint-by-intuit/karate-web-services-testing-made-simple-366e8eb5adc0#.qnpy5gagt

Unit-testing ExtJS app with Selenium

How do you go about unit-testing ExtJS web apps using Selenium?
Can you point me to some web resources or book regarding this issue?
What pieces of your application are you looking to test using Selenium? Unit testing implies smaller pieces than a full "UI" test, from my perspective. If you're looking to do true unit testing, you will probably want to pull in some library like jsUnit or qUnit and then just have Selenium run those tests, and then grab the resulting information.
I haven't directly used Selenium to test the view itself, since I've always considered that to be pretty solid, coming directly from the Sencha crew. If you're trying to go down this road, your best bet would probably be to search the official selenium user group. They appear fairly active. The user group would potentially be a good resource for asking questions, as well. While keeping in mind that ExtJS is just a powerful way to alter the DOM in a very dynamic fashion.
...and I just noticed the links off to other pages that have already been provided. Still valid data, so I'm going to post it anyways. :)

Is it right to only test my controllers in an MVC web app running in the Microsoft cloud and using table storage?

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.

Run django tests from a browser

I'd like to provide a browser page to help non-techies run the various tests I've created using the standard django test framework.
The ideal would be for a way to display all the tests found for an application with tick boxes against each one, so the user could choose to run all tests or just a selection.
Output would be displayed in a window/frame for review.
Anyone know of such a thing?
Not quite what you've asked, but sounds a bit like Fitnesse, which allows non-technical users to define tests in a wiki-like syntax and run them from the browser. It is possible to link this up to Django's test framework.