Sunday, March 21, 2010

JUnit

As requested posting a blog about Junit

What is Junit ?
Simple framework for writing and running automated tests. Includes useful abstractions for running tests including test cases, text fixtures and test suites.

package junit.samples;


import junit.frameworks.*;
import java.util.Vector;
import junit.extensions.*;


/**
* sample test for java.util.Vector
*/
public class VectorTest extends TestCase {
  protected Vector fEmpty;
  protected Vector fFull;


public VectorTest(String name) {
      super(name);
}
public static void main (String[] args) { 
      junit.textui.TestRunner.run (suite());
}
...
protected void setUp() {
  fEmpty = newVector();
  fFull = new Vector();
  fFull.addElement(new Integer(1));
  fFull.addElement(new Integer(2));
  fFull.addElement(new Integer(3));
}
public static Test suite() {
    return new TestSuite(VectorTest.class);
}
public void testCapacity() {
       int size= fFull.size();
       for (int i=0; i < 100; i++)
          fFull.addElement(new Integer(i));
       assertTrue(fFull.size() == 100+size);
}
public void testClone() {
   Vector clone =  (Vector)fFull.clone();
   assertTrue(clone.size() == fFull.size());
   assertTrue(clone.contains(new Integer(1)));
}
}
...


What is JUnitPerf ?
Collection of JUnit tests decorators used to measure the performance and scalability of functionality contained within existing JUnit tests. When ever performance and scalability requirements are critical, JUnit perf plays an pivotal role.

Supported JUnit test decorators:

Timed tests: Runs a test and measures elapsed time

Load tests: Runs a test with concurrent users and iterations

Threaded tests: Runs a test in separate thread

JUnitEE: This is an extension to Junit. It allows tests to be executed inside an application server. Hence tests run in production environment.

Code Coverage Tools:

Emma - I have used Emma as well as our own version of Clover in my previous company. One can find all information about Emma at emma.sourceforge.net

Clover is commercial, free to open source project. Here is an example image for a cal app:


Qualities of a good Engineering or Test Manager

I have been fortunate to be reporting to a quality Test managers in the past. Looking at my past experience as well as current experience of reporting to test manager or a director led me to write this blog:


According to me whether you are explicitly a test manager or QA manager at least you should have following qualities.



  • Having domain expertise of the product that you are managing
  • Technical knowledge about the technology or tools being used in an organization they are managing - if not expertise but some sort of knowledge
  • Ability to have an healthy/productive technical discussion with reporters
  • Ability to provide career guidance, recognize skill set, assign appropriate role
  • Test manager should not under estimate reporters or co-workers
  • Should have execellent knowledge of software development process
  • Should always promote a positive atmosphere in the team
  • Must promote teamwork to increase productivity
  • Must maintain enthusiasm of team
  • Must have preventive approach to the problems
  • Must be able to promote cooperation between software, test, and QA engineers
  • Should have the ability to promote improvements in QA processes
  • Should have people judgement skills for hiring and keeping skilled personnel
  • Should be able to organize meetings and keep them focused
  • Good communication skills to communicate well with technical & non-technical people, engineers, managers and as well as with customers.
  • Ability to say ‘no’ to other leads / managers when quality is insufficient or QA processes are not being adhered.




Basically it all can be divided in top 5 points:


Creativity:You can never solve a problem on the level on which it was created. Discovery of new ideas or concepts. A good manager should be able to welcome/encourage new ideas or concepts. Be able to discuss pros and cons of such new idea or concept. Say for example, exploratory testing by various stakeholders or integrating guiceberry with junit3 or use of testng instead of junit3.


Leadership Skills: Leadership, a critical management skill, is the ability to motivate a group of people toward a common goal. These items will help you develop your skills as a leader.

  • Talking out loud
  • Having a positive attitude
  • Able to be change the perspective
  • Effective convincing skills to deal with various stakeholders
  • Able to recognize skill sets and assigning tasks

Organization Skills:Practicing good organizational skills helps you to be prepared for your day-to-day responsibilities. Organizing your home, school or office will help you to work more efficiently, in whatever tasks you wish to accomplish.

  • Significance: Good organizational skills are significant because they help you to function better in everyday activities, from getting dressed in the morning to remembering appointments and meeting deadlines.
  • Function: Being organized helps you to know what is expected of each day and to be prepared to meet those expectations. For example, creating a list of things you need prior to going to the store will make you a more effective manager of both your time and your money.
  • Considerations: Consider the importance of being organized if you are in school and have to be responsible for assignments, if you have to keep appointments for your job or if you are running a household.
  • Warning:Avoid overwhelming yourself with maintaining organization. It is often easy to be just as overwhelmed as you try to keep up with your new skills, as it is to be unorganized and cluttered. Ease your way into new organizational habits.
  • Benefits:Good organizational skills will help you to finish tasks you begin. Focusing on completing a goal in an organized manner will enable you to eliminate things that may otherwise cause a distraction.



Knowledge: Having domain expertise of the product or project is as important as being skill-full about the technologies or tools used - whether its a bugs tool or test case management tool. A good test manager will always be aware and be proactive about learning new technologies that are being used within his organization. For example test case management tool or bugs tool. Its essential to have a thourough knowledge about such tools which are used in day to day activities by entire QA organization. In terms of finding metrics or planning upcoming release cycle, these both tools play key role in providing visualization of various metrics like bug count, bug history, trends and patterns - which are looked upon by various stakeholders.


Innovation, Motivation, Enthusiasm: Extremely important. A good test manager should be able to motivate various members within his organization either by appreciating there work or making them responsible to take over a challenging project, where team member not only get an opportunity to prove himself (visibility) but also gets an opportunity to learn something new.
In my past company I was involved in developing a SDK which can be used to develop dashboard(s) or gadgets to provide various metrics. It gave me an opportunity to prove myself, huge huge visibility, learn new techs like GWT, Gviz!!!!
Another aspect could be innovation! Being innovative, being a pioneer of say a process or a framework!! In my past company I was involved in help automating release process. Understanding release process not just related to my own project but also to learnt it across various projects within same organization and then gathering requirements from various teams, stakeholders, outlining in terms of priority, presenting to higher authorities. And then designing which tech or lang to used to build, what are commonalities across board etc. After that comes actual implementation. 
Enthusiasm - Being enthu about work you are actually performing and also be able to create equal amount of enthusiasm across board withing team members is as critical as motivation. If you do not feel enthu about your work then its very hard to keep team motivated! Without the enthusiasm to support their activities, it is extremely doubtful that the QA and Testing function will be successful. Doubt and negativity will only reinforce a perception that the QA and testing activities are not as value-added as programming activities and are a drain on schedule and budget.  Enthusiasm is rare, however. Most employees want to do a good job, but they feel under appreciated. Generally, bad management is blamed for unmotivated workers, but often, good management can still provide unenthusiastic workers. So, what's the secret?
If your own employees aren't acting motivated or aren't acting enthusiastic, then it's time to get your own "act" in gear. You can fire up your workforce in three acts: 
Act enthusiastic. Act grateful. Act happy.
Psychologists tell us that the best way to change our feelings about what we're doing is to change the way we think of our feelings. The brain tells the body how to feel and the body acts accordingly. We can direct our own feelings and our outlook on life. Writing in Out of Work? Get Into Business!, I wrote about expectations and how they can change the outcome of future events


Team Member:
Working on teams can be rewarding, but at times it can be difficult and downright frustrating. If there are poor communicators on your team, you may often feel left in the dark, confused or misunderstood. To create a successful team, effective communication methods are necessary for both team members and leaders. To have an effective team or be able to build team spirit, following norms usually been followed or enforced by a good test or quality manager.


  • Team members as coworkers: all team members are equal; every team member's opinion will be thoughtfully considered; each team member will keep all commitments by the agreed upon due date; each team member agrees to constantly assess whether team members are honoring their commitment to the team norms.
  • Team member communication: team members will speak respectfully to each other; will not talk down to each other; will positively recognize and thank each other for team contributions.
  • Team member interaction in meetings: team members will listen without interrupting; hold no side or competing conversations; follow the rules for effective meetings; attend the meeting on time; always work from an agenda; minutes will be recorded at each meeting; end meetings on time.
  • Team organization and function: leadership will rotate monthly; the team management sponsor will attend the meeting, at least, monthly.
  • Team communication with other employees including managers: team members will make certain they have agreement on what and when to communicate; complaints about team members will be addressed first in the team.
  • Team problem solving, conflict resolution, and decision making: team members will make decisions by consensus, but majority will rule if timely consensus is not reached; conflicts will be resolved directly with the persons in conflict