viernes, 29 de julio de 2016

Simple solution for simple error


The most interesting thing in the software develop is the ease with which error occurs. In some
occasion the error is for a bad code, other because the person forgot programing some exception and in stranger case the cause is stranger
In some moment of this two weeks I discover the cause of a stranger error in a gulp task. But, before to explain the error and the steps to resolve this I explain you how is a gulp


Gulp

Gulp is a JavaScript task runner La principal idea of it is that you can programing a predefined task, for example:

  • Insert the localization of important files in the index.
  • Review the syntax of the program
  • Start a server to run an application.

The mysterious error in a gulp task

The first time that I execute the gulp task I found an interesting error in the console when the task for the review of the syntax has executed




The information of the error is very simple but no have sense. I discovered that my project not have an important file for the task: .jscsrc. If you search in Google this file you discover that is a file configuration with rules for the syntax. This file you can created yourself or use a predefine rules.

Resolve the error

So, you need file. How create this files? Simple, you need to follow the next steps:
1. Install this package npm install jscs –g
2. Run this command to generate JSCS configuration jscs --auto-configure path. Where path is the folder of you have the scripts.
3. When the command finally, you see something that it :

The number are the type of rules that you can choose. In the case for my project I use grunt, but you can use anything. When you choose the best option for you, the console inform that you have a .jscsrc file create.

If you run again your task, it have to works. This technique is utile if your report of error is different of the report of other members in your team, because it update de .jscs file.

jueves, 14 de julio de 2016

Unit Test How start with it?

All the programmers have a technique to test the software than they made.
In some cases this technique is print in console the result of a things or test the functionality with examples in the interfaces, but this method cannot be effective.
For our lucky, in some language we have a very effective method, during this two week I discover a very effective method, the Unit Test.
The unit test is a good method to test the functionality of the class methods in your program. So, I have some important points that you need to know if it is your first time with unit test. So go ahead.


Correct Configuration


The magic of the unit test is the correct configuration of the necessary files, if you don’t have it, the test is going to fail, even if the sentences that you can test is simple. For example, test that the true sentence is true or compare a simple string. When it happen you need to review the dependence of your project. Try to change the angular dependence mock and animate, for the same version of angular. It resolve the problem with the fail test without reason.

Know how testing

This is an interesting topic, because, how do know what you need to testing? So, it’s really easy, only what you need is to know what your module do and test what do you need that the methods in the module do. If you have problems with this you can use the coverage of PhantomJS, it is very effective to see the percentage of the functionality test and to know how is not testing yet


Using Spy

Yes, nobody like to be spy, but in this situation is good. The spy option of jasmine allow you see what the object methods do and permit to test if it is called. So, use it with trust. In this case the SpyOn method in Jasmine is your friend.

Create Mocks

Angular have a library special to create a false function or data to be testing, this is usefel when you need test a service that is used in the controller o when you have your data in a database. Tne name of the library is ngMocks,is important to remember when installe the ngMocks is that the version have been the same version of Angular. You can configure this in your karma file.


All this things are simple and necessary to be a unit tester. If you need to learn more about it, you need to practice and search information about unit testing, for your lucky, the web have more information about it.