Subscribe by Email


Showing posts with label Unit tests. Show all posts
Showing posts with label Unit tests. Show all posts

Friday, June 22, 2012

What are different types of smoke tests?


Smoke testing has merged as one of the best general software testing methodology though it is a dirty one and very shallow too! Smoke testing is one of the easiest and quickest black box software testing methodologies that we have today. 

Smoke tests are of two types namely:
1. Functional tests and
2. Unit tests

About Functional Tests


- These type of smoke tests are typically scripts or programs that have been configured to test the group of classes so as to determine whether or not they meet the external requirements.
- One example of functional tests is the screen- driving programs that are used to test the graphical user interfaces (GUIs).
- They are a certain class of black box tests that are based up on the specifications of the software components under testing. 
- The testing is carried out normally i.e., giving the input and observing the output and the internal structure of the system is neglected.
- Functional tests are implanted via the following 5 steps:
(a)  Identifying the functions that are to be performed by the software system.
(b)  Creating the input data that is based up on the specifications of the functions.
(c)   Determining the output based up on the specifications of the functions.
(d)  Executing the test case.
(e)  Comparing the actual and expected outcomes.
- The functional smoke tests form a key component of the software engineering as they help track the growth of the project.
- Using the functional tests, the system can be tested from end to end. 
- Similar to the unit tests the functional tests accelerate the development rate of the project while ensuring its quality. 
- Functional tests are specified by the customers or the customers may provide the developers with user stories based on which the developers may write the functional tests. 
Errors that are encountered during functional tests are fixed using the unit tests and then again verified by the functional tests. 
- The more the number of functional tests and the more correct they are, the more is the certainty that the software system or application is working. 
- To make this whole process efficient, you need to automate the whole testing process.

About Unit Tests


- For carrying out these types of smoke tests you need a unit test frame work that will create automated unit tests suites. 
- Another thing is that all the classes within the build should be tested. 
- The tests are created before the code is written. 
- The code repository holds the unit tests along with the code that is to be tested. 
- Automated unit tests though are difficult and take a lot of time, yet they offer huge pay back. - It takes a lot of time to produce a good unit test suite. 
- The unit tests enable the following aspects:
(a) Collective ownership: This eliminates the need for individual code ownership since all the classes are guarded by the unit tests.
(b) Re-factoring: This ensures that a change in one part has not hampered the performance of the other parts.

About Frequent Integration

- This is possible only if there is a single universal unit test suite for regression testing and validation. 
- When your unit tests are automated it becomes easy to merge the changes with the latest released version. 
- Whenever a new functionality is added it is required that the unit tests are also changed  accordingly to reflect the functionality. 


Thursday, May 3, 2012

What are the requirements in a test driven development?


The test driven development is often abbreviated as “TDD” and has been recognised as one of the common development strategies that are quite popular among the developers and the programmers. 

What is a Test Driven Development?
- This development methodology involves the repetition of short typical development cycles.
- These development cycles are shorter in duration when compared to the usual development cycles of the other software development strategies.
- The developer first requires writing a failing automated test case defining a desired new function or an improvement in an already existing function. 
- A code is then written to pass the test and later it is subjected to refactorization to meet the acceptable standards. 
- Test driven development is often considered to be related to the extreme programming to some extent.
But, now it is being considered as a development process of its own rules and objectives.
- The test driven development also serves to improve and debug the legacy code that has been developed using the other methodologies. 

No development methodology can be carried out further without requirements, this holds true for the test driven development also. This article emphasize on the requirements of the test driven development. 

Requirements in a Test Driven Development
- The whole methodology of test driven development is supported by a set of unit tests that are automated. 
These automated test cases are written in order to define the requirements of a particular piece of the code. 
- Such unit tests first identify the requirements and then immediately write down the code for the identified requirements all by themselves. 
- Certain assertions i.e., the true and false values are also contained in those automated unit tests. 
- The code is continually evolved and re-factorized and then subjected to testing via the automated unit tests which are put up on an automated testing frame work such as xUnit.
- Such frame works facilitate the automatic execution of the unit tests.
- These small unit tests drive the development of a small fragment of the solution.
- These unit tests also serve a tested and canonical documentation for the usage of the program’s object. 
- In the test driven development, writing the test is given the first preference rather than writing the code first. - But, this approach is considered to be difficult by many of the software programmers and developers and even some resist the use of the test driven development methodology since for them it turns out for them as the upside down approach for development.
- The test driven development methodology takes in to consideration the fact that the test is the rightmost important thing and it is required that we make sure that the test passes. 

But what is to be done if the unit tests itself are wrong and do not suffice for providing adequate coverage to the code? 

- If it is the latter case i.e., if the tests are not able to provide enough coverage then there is one possibility that your unit tests are missing out some of the requirements of the code. 
- This often happens in the case of manual testing but not so when we use the automation techniques.
- Automated unit tests make sure that no requirement of the code is left uncovered.
- So, the quality of the unit tests defines the quality of the whole test driven development process also. 

Starting with the requirements is known as the top down approach and is more commonly followed than the bottom up approach. The requirements are treated as the executable tests which are clarified by the managers, stake holders and developers. 


What is meant by test driven development (TDD)?

Test driven development or TDD is another process in the league of the software development processes. The topic of the test driven development is in the spot light of this article. The test driven development follows from the idea of the repetition of a very short development cycles. 



Concepts of Test Driven Development (TDD)


- First of all a failing automated test case is written or created by the developer or tester which serves the purpose of defining a new function or a desired improvement. 
- Then a code to pass the above created test is also created by the developer. 
- This newly written code is then refactored in order to make it meet the acceptable standards.
- Kent Beck is credited with the discovery of the test driven development process in the year of 2003. 
- The test driven development was looked up as an encouragement for the simple designs and also as an inspiration for boosting up confidence levels.
- The test driven development has always been related to the concepts of the extreme programming which took its root in the year of 1999. 
- But, eventually it came up as an individual process with its own ways and rights. 
- The concepts of the test driven development are also employed by the programmers and developers as a measure for debugging the legacy code and improving it further. 
- The test driven development is driven by a series of automated unit tests that are created by the developer for defining the requirements of the code and then automatically produce the code for them. 
- These unit tests are comprised of assertions i.e., either true values or false values. 
- Successful passing of a test confirms the developer of the correctness of the code and that it can be further evolved and re-factored. 
- To run these automated test cases, the developers make use of the testing frame works.



Steps involved in Test Driven Development (TDD)




Addition of a Test: 
The development begins with the creation of test cases for all the features. These test cases are often expected to fail since they have been created before the implementation of those features. If these test cases do not fail then either the test case is having some defect or the proposed new feature is already in existence. Before writing the test case, the developer is supposed to fully understand the specifications and requirements of the feature using the user stories and use cases etc. This is what that makes the test driven development different from other development methodologies.


Execution of all tests in order to check the working of the new one: 
This step involves the validation of the test harness for its correct working. At this step this is also ensured that the new test is not passing without the requirement of some new code. The test itself is also tested in negative and the possibility that the newly added test will always pass out is reduced. The new test is also expected to fail because of the reason figured out.


Production of code: 
This step involves the creation of some code implementing which the code can only pass the test and does not incorporates any new functionality.


Execution of the automated tests and observing their success.


Re-factoring of code: 
This step involves the cleaning up of the code.


Repetition: 
The whole cycle is repeated for the improvement of the functionalities.


Many development styles have been developed for the test driven development like:
  1. YAGNI (you ain’t gonna need it)
  2. KISS (keep it simple stupid) etc.


Monday, April 16, 2012

What are automated unit tests?

Automated unit tests can be thought of as the basic tools with the help of which the unit testing is carried out on the individual modules of the software systems and applications.

Without these automated unit tests, one cannot think of carrying out unit testing since it takes up too much of time. These automated unit tests test the whole unit or the module along with the associated below mentioned things:

1. Its control data
2. Usage procedure
3. Operating procedures and so on.

Since the units or the modules form the smallest tokens of any software system or application, hence the unit testing forms the first step of any software testing life cycle.

What are automated unit tests?



- In procedural programming, these automated unit tests usually cover up the individual procedures or functions.

- In object oriented programming an automated unit test may cover an entire interface for example a class, individual method and so on.

- The automated unit tests are usually developed by the developers, programmers sometimes but more commonly they are created by the white box testers because they have so much of knowledge about that particular software system or application under test.

- They are created simultaneously with the software development process.

- All of the automated unit tests created for a software system or application are quite different from one another and they are assisted by a variety of separate elements like those mentioned below:

1. Method stubs
2. Mock objects
3. Fake objects
4. Test harnesses and so on.

- The above mentioned elements help the automated unit tests in testing a module in isolation.

- The automated unit tests though created by the white box testers, are executed by the software developers since testing this way ensures that all the specifications and the requirements of the software system or the application are fulfilled and the program executes in the desired direction.

- The concept of the automated unit tests came in to existence to formalize the implementation of the automated unit testing as a part of the build automation which would have been a hectic task if carried out manually.

- The automated unit tests are aimed at isolating each and every part of the program and check whether they are working properly or not.

- An automated test being strict provides a written contract that is to be satisfied by the piece of code for which it is meant.

Benefits of Automated Unit Tests



In simple words, we can say that it affords many simple benefits!

- Automated unit tests have been known for years to find problems earlier in a software development life cycle.

- Most of the agile software development methodologies like the scrum and the extreme programming (XP) involve the creation of these automated unit tests before the production of the actual code.

- Later the code is written and is run through the test.

- If it passes, then the code is declared to be error free.

- With these automated unit tests, the program code can still be refactored and checked again with the same automated unit test till the code is considered to be complete.

- These automated test cases facilitate the quick checking of all the functions and modules for quick identification and fixation of the problems if any encountered.

- These automated unit tests have a characteristic which is that they reflect the way in which the code is intended to execute.

- Depending up on the test coverage of these unit tests and development practices in use, the automated unit tests can be made more accurate.

- Apart from all this, the automated unit tests do a better job when it comes to the reduction of the uncertainty in the program.


Facebook activity