Wednesday, July 09, 2014


If you face this problem, probably you are using Ant tasks that include the javac task for compiling Java source. This simply means that Ant could not find a Java compiler.

BUILD FAILED
D:\research\ant\firstbuild\build.xml:9: Unable to find a javac compiler;
com.sun.tools.javac.Main is not on the classpath.
Perhaps JAVA_HOME does not point to the JDK.
It is currently set to "C:\Program Files\Java\jre7"

Total time: 0 seconds

For Eclipse user you can add items to Ant’s class-path from the Ant > Runtime preference page. If you launch Eclipse by using a full JDK instead of a JRE, tools.jar should appear on the Ant class-path automatically.


Thursday, July 03, 2014

Today, I just tried to install a sample CodeIgniter project in  LAMPP (Ubuntu) machine. I received a following error message in browser, when I try to browse the application.

Message shows some how I am not able to connect to database. I checked the configuration at /opt/lampp/htdocs/doasoil/core/application/config/database.php (path will be different in your case) and everything seems OK to me.

Thursday, June 26, 2014



"There is no security on this earth; there is only opportunity." Are you often engage in million dollars deal, if your answer is yes then Beware eavesdropping attackers and opportunistic are sniffing your call! The Prism surveillance scandal has shown that the NSA and other agencies can tap into most communication channels.


In such a case, security is paramount and for that, RedPhone an open source app Licensed under the GPLv3: http://www.gnu.org/licenses/gpl-3.0.html

Wednesday, June 25, 2014

I am not sure whether the features is available for all version of virtual box, so first confirm that the version of virtual box you have.Mine version is 4.3.6 and features is already available, and following steps will guide you to share file between host to guest and vice-verse.

1. Open "Oracle VM Virtual Box" manager and click on "Shared Folders" link where you can adds a new shared folder definition.Following figure will help you to visualize this.




2. In Add Share form you can mention the "Folder Path" i.e the location you want to share, "Folder Name" which is a name used to identify from guest side. Also do not forget to check "Auto Mount" and "Make Permanent" option otherwise you need to do this manually later from command line.



That's it now you can start the Virtual Machine, if it is already started you have to reboot it to make the mount volume available in system. The shared folder appears on your guest machine as:

/media/sf_folder_name

For example:

/media/sf_ProjectsWindows

Oh yes, there is one more step add any user in your guest system that needs access to the folder to the group vboxsf.

Tuesday, June 24, 2014

I was installing MySQL-python in Ubuntu, for this I downloaded package file from MySQLdb Download page and proceed as follows:

$ gunzip MySQL-python-1.2.2.tar.gz
$ tar -xvf MySQL-python-1.2.2.tar
$ cd MySQL-python-1.2.2
$ python setup.py build
$ python setup.py install

Note: Make sure you have root privilege to install above module.

When I reached the steps 4 in above process i.e "python setup.py build" I received the following error messages.

sh: 1: mysql_config: not found
Traceback (most recent call last):
  File "setup.py", line 18, in 
    metadata, options = get_config()
  File "/home/user/Downloads/MySQL-python-1.2.4b4/setup_posix.py", line 43, in get_config
    libs = mysql_config("libs_r")
  File "/home/user/Downloads/MySQL-python-1.2.4b4/setup_posix.py", line 25, in mysql_config
    raise EnvironmentError("%s not found" % (mysql_config.path,))
EnvironmentError: mysql_config not found

Seems like something is missing in my OS.

As we know MySQLdb is simply a python interface for mysql, but it is not mysql itself and MySQLdb setup process apparently using mysql_config, so you need to install that first, but first confirm whether mysql_config added in system path or not. If it was not added you can do it as follows.

export PATH=$PATH:/usr/local/mysql/bin/

If you do not want add mysql in path, just run something like this to make mysql_config available:

ln -s /usr/local/mysql/bin/mysql_config /usr/bin/mysql_config

Since this is the path that python will search by default. If mysql_config is not already installed you can do it as follows:

apt-get install libmysqlclient-dev


Saturday, May 31, 2014

Many people and organizations are confused about the difference between quality assurance (QA), quality control (QC), and testing. They are closely related, but they are different concepts. Since all three are necessary to effectively manage the risks of developing and maintaining software, it is important for all to understand the differences.

I need to get something straight: QA and QC are different. Why must I point this out? Because programmers don't seem to get it and use these terms interchangeably. While it is usually enough to get your point across with a developer, it is helpful to think about these terms and how they apply to the world of software testing

QA is Quality Assurance  : A set of activities designed to ensure that the development and/or maintenance process is adequate to ensure a system will meet its objectives. , It is a process of verifying predefined requirements for quality. the QC function  involve checking the software against a set of requirements and verifying that the software meets the predefined requirements.

but

QC is Quality Control : A set of activities designed to evaluate a developed work product. It  is much more about providing the continuous and consistent improvement and maintenance of process that enables the QC job. We use the QC process to verify a product does what we think it does, and we use the QA process to give us confidence that the product will meet the needs of customers. To that end the QA process can be considered a meta process that includes aspects of the QC process. It also goes beyond that to influence usability and design, to verify that functionality is not only correct, but useful.

Whereas:

Testing(Tester or Test Engineer) is : The process of executing a system with the intent of finding defects. (Note that the "process of executing a system" includes test planning prior to the execution of the test cases.)
The difference is that QA is process oriented and QC is product oriented.

Testing, therefore is product oriented and thus is in the QC domain. Testing for quality isn't assuring quality, it's controlling it.


Quality Assurance - QA
Quality Control - QC
Quality Assurance makes sure you are doing the right things, the right way
Quality Control makes sure the results of what you've done are what you expected
QA is a failure prevention system that predicts almost everything about product safety, quality standards and legality that could possibly go wrong, and then takes steps to control and prevent flawed products or services from reaching the advanced stages of the supply chain.
QC is a failure detection system that uses a testing technique to identify errors or flaws in products and tests the end products at specified intervals, to ensure that the products or services meet the requirements as defined during the earlier process for QA
QA department develops all the planning processes and procedures in order to try to make sure that the products manufactured or the service delivered by the organization will be of good quality
QC department checks the products or services for defects that happen due to these parameters, trying to achieve the overall QC objective of providing a defect-free product or service to the customers.
QA defines the standards/methodology to be followed in order to meet the customer requirements.
QC ensures that the defined standards are followed at every step
In general, the QA activities are done before the product is manufactured or the service delivered (proactive approach).

The QC activities are done during the manufacturing process and once the product is manufactured
QA tasks are conducted by managers, Leads ,third party auditors, and customers
QC tasks are executed by experts who are directly involved with the design, or manufacture of a product on the shop floor such as engineers, inspectors, etc
- A QA audit would focus on the process elements of a project. e.g.: Are requirements being defined at the proper level of detail?
- Process documentation
- Establishing standards
- Developing checklists
- Conducting internal audits

- A QC review will focus on product elements. e.g.: Are the defined requirements the right requirements?
- Performing inspections
- Performing testing

* For this reason, one person cannot perform both activities (QA and QC) because will result in a conflict of interest.

So to summarize,
QC detected a recurrent problem with the quality of the products. QC provides feedback to QA personnel that there is a problem in the process or system that is causing product quality problems. QA determines the root cause of the problem and then brings changes to the process to ensure that there are no quality issues in future.

Finally,
Both departments are essential to maintain good quality of the deliverable s. And keep in mind no matter how you define QA and QC,  the goal is: to delivery good quality.


Friday, May 16, 2014


Today when I execute mysql -uroot -p command in ubuntu console I get this error message.

mysql: symbol lookup error: /usr/local/lib/libreadline.so.6: undefined symbol: UP

Problem started when I updated my current readline library to 6.3 version. So here is the quick fixes for this problem.

1. First of all login as "root" user. Following command will help you to do this.
user@localhost:~$ sudo su

2. Go to folder /usr/local/lib and check libreadline exist or not.
root@localhost:/home/user# cd /usr/local/lib
root@localhost:/usr/local/lib# ls -la libreadline*

Output:

-rw-r--r--  1 root root  1427712 May 11 18:03 libreadline.a
-rw-r--r--  1 root root  1427712 May 11 18:02 libreadline.old
lrwxrwxrwx  1 root root       16 May 11 18:03 libreadline.so -> libreadline.so.6*
lrwxrwxrwx  1 root root       22 May 11 18:13 libreadline.so.6 -> libreadline.so.6.3.old*
-r-xr-xr-x  1 root root   829465 May 11 18:03 libreadline.so.6.3*
-r-xr-xr-x  1 root root   829465 May 11 18:02 libreadline.so.6.3.old*

3. Now create a temporary folder and create a backup of these libraries. Actually we are going to remove these libraries, and in case of emergency you know what to do.

root@localhost:/usr/local/lib# mkdir /tmp/libreadline_bk
root@localhost:/usr/local/lib# mv libreadline.* /tmp/libreadline_bk/.

4. Now type `ldconfig` in console. According to man page of ldconfig:

ldconfig  creates  the  necessary links and cache to the most recent shared libraries found in the directories specified on the command line, in the file /etc/ld.so.conf, and in the trusted directories (/lib and /usr/lib).

root@localhost:/usr/local/lib# ldconfig

5.  Now type apt-get update. It take some times and you need Internet connectivity to complete this step
root@localhost:/usr/local/lib#apt-get update

 After this update the problem should solved.

Monday, March 31, 2014

Did you enter the wrong password multiple times in Weblogic Admin User? If answer is yes, then probably your account is locked for temporary period of time. If you tail the server log you can find the following error message. 

####     <[ACTIVE] ExecuteThread: '4' for queue: 'weblogic.kernel.Default (self-tuning)'> <> <> <> <1395127313511>  

Message shows "User weblogic in security realm myrealm has had 5 invalid login attempts, locking account for 30 minutes." 

PROBLEM??? 

As the log mention issue should be resolved within 30 minutes, however if you do not want to wait that longer, then you need another admin account. There after you can use weblogic.Admin which is a command-line utility for managing WebLogic Server. Please follow the following steps: 

1. Make Sure that "weblogic.jar" is added in the CLASSPATH manually. You can do this or you can use the Script provided by WebLogic to do this. Script is available Here (<BEA_BOME>/<WL_HOME/server/bin/setWLSEnv.sh) 

cd /home/wls/bea/wlserver_10.3/server/bin/ 
. ./setWLSEnv.sh

NOTE: There are two Dots before the Script separated by a Single Space. First Dot represents that set the environment in the Current Shell and Second Dot represents that pick the Script from current Directory.

Output: 

CLASSPATH=/home/wls/bea/patch_wlw1030/profiles/default/sys_manifest_classpath/weblogic_patch.jar:/home/wls/bea/patch_wls1030/profiles/default/sys_manifest_classpath/weblogic_patch.jar:/home/wls/bea/patch_cie660/profiles/default/sys_manifest_classpath/weblogic_patch.jar:/home/wls/bea/jrockit_160_05/lib/tools.jar:/home/wls/bea/wlserver_10.3/server/lib/weblogic_sp.jar:/home/wls/bea/wlserver_10.3/server/lib/weblogic.jar:/home/wls/bea/modules/features/weblogic.server.modules_10.3.0.0.jar:/home/wls/bea/wlserver_10.3/server/lib/webservices.jar:/home/wls/bea/modules/org.apache.ant_1.6.5/lib/ant-all.jar:/home/wls/bea/modules/net.sf.antcontrib_1.0.0.0_1-0b2/lib/ant-contrib.jar:

PATH=/home/wls/bea/wlserver_10.3/server/bin:/home/wls/bea/modules/org.apache.ant_1.6.5/bin:/home/wls/bea/jrockit_160_05/jre/bin:/home/wls/bea/jrockit_160_05/bin:/usr/lib64/qt-3.3/bin:/usr/local/WebLogic/10.3.0.0/jrockit-R27.5.0-jdk1.6.0_03/bin:/usr/local/ant/1.6.5/bin:/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/root/bin:/home/wls/bea/jrockit_160_05/bin

Your environment has been set.

If you forget to add the jar in classpath you will receive the following message.

Exception in thread "main" java.lang.NoClassDefFoundError: weblogic/Admin
Caused by: java.lang.ClassNotFoundException: weblogic.Admin
        at java.net.URLClassLoader$1.run(URLClassLoader.java:200)
        at java.security.AccessController.doPrivileged(Native Method)
        at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
        at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:276)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:251)
        at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:319)


2. Open a command Prompt (Shell Prompt) and then move to the <BEA_BOME>/<WL_HOME/server/bin directory and run the following Script.
 

java [<SSL trust options>] weblogic.Admin
        [ [-url | -adminurl] [<protocol>://]<listen-address>:<port>]
        -username <username> [-password <password>]
        <COMMAND> <ARGUMENTS>
       

Example: 


java weblogic.Admin -adminurl localhost:7001 -username admin2 -password password invoke -mbean Security:Name=myrealmUserLockoutManager -method clearLockout admin1

You will receive the message "OK" if command executed successfully.

Friday, March 28, 2014

Sometimes even if you deleted the large files for example log files created by Weblogic server, Apache Tomcat, Mysql and others disk space is not available in the system. It is because the file is being used by these applications and not able to release the space occupied by file.
In that case you have to identify the processes using these deleted files. To do so you can take the help of linux proc directory which is pseudo-file system used as an interface to kernel data structure. proc directory contains /proc/[pid]/fd subdirectory.
This subdirectory containing one entry for each file which  the  process  has open,  named  by  its  file descriptor, and which is a symbolic link to the actual file.  Thus, 0 is standard input, 1 standard output, 2 standard error etc.

Alright lets begin the work.
1. Type the following command in your bash shell

 ls -la /proc/*/fd/* 2>&1 | grep deleted  

Where
  • 2 is the default file descriptor for stderr.
  • 1 is the default file descriptor for stdout.
  • >& is shell syntax for "fold a file descriptor into another"
Here 2>&1 means redirect stderr(2) to stdout(1). At first, 2>1 may look like a good way to redirect stderr to stdout.  However, it will actually be interpreted as "redirect stderr to a file named 1". & indicates that what follows is a file descriptor and not a filename. So the construct becomes: 2>&

Output:
lrwx------ 1 root   root     64 Mar  7 03:20 /proc/1437/fd/3 -> /tmp/vmware-root/appLoader-1437.log (deleted)

lrwx------ 1 oracle oinstall 64 Mar  7 03:20 /proc/7550/fd/3 -> /tmp/vmware-oracle/appLoader-7550.log (deleted)

l-wx------ 1 root root 64 Mar 26 04:27 /proc/3675/fd/340 -> /usr/local/WebLogic/wlApps/mi/mi.8202/WebContent/WEB-INF/log/spring.log (deleted)


2. Here we identify 3 process ids 1437 ( from /proc/1437/fd/3), 7550 (from /proc/7550/fd/3) and 3675 (/proc/3675/fd/340) . We can grep these processes to identify which program actually using these files. Let's grep one process.

ps aux | grep 3675 
Output:
root      3675  0.5 14.8 5573700 2448684 ?     Sl   Mar03 200:54 /usr/local/WebLogic/10.3.0.0/jrockit-R27.5.0-jdk1.6.0_03/bin/java -jrockit -Xms2g -Xmx2g -Xverify:none -da -Dplatform.home=/usr/local/WebLogic/10.3.0.0/wlserver_10.3 -Dwls.home=/usr/local/WebLogic/10.3.0.0/wlserver_10.3/server -Dweblogic.home=/usr/local/WebLogic/10.3.0.0/wlserver_10.3/server -Dweblogic.management.discover=true -Dwlw.iterativeDev= -Dwlw.testConsole= -Dwlw.logErrorsToConsole= -Dweblogic.ext.dirs=/usr/local/WebLogic/10.3.0.0/patch_wlw1030/profiles/default/sysext_manifest_classpath:/usr/local/WebLogic/10.3.0.0/patch_wls1030/profiles/default/sysext_manifest_classpath:/usr/local/WebLogic/10.3.0.0/patch_cie660/profiles/default/sysext_manifest_classpath -Dweblogic.Name=mi.8202 -Djava.security.policy=/usr/local/WebLogic/10.3.0.0/wlserver_10.3/server/lib/weblogic.policy weblogic.Server

Output shows Weblogic Server version 10.3.0.0 using the file /usr/local/WebLogic/wlApps/mi/mi.8202/WebContent/WEB-INF/log/spring.log.

3. Now we have to kill this process to regain our space.
 kill -9 3675 

Monday, March 17, 2014

There are various ways to identify how long the widows system has been running . Some of the methods are listed below.

1) To find the uptime in graphical ways just open up Task Manager by right clicking the Taskbar and selecting Task Manager.


Click on the Performance tab of Task Manager and you will see the amount of up-time listed under the System section.


2) In Command line method Start Run (Windows Key + r) and type cmd and click ok. 


In command prompt type "systeminfo" without the quotes and hit enter. It will take some time to complete the analysis process and get the results.  In the list you will see the System Boot Time listed in mm/dd/yyyy hh:mm:ss AM/PM format. If  you want to list only boot time type systeminfo | find "Boot Time"



 3) We can also find the uptime using following commands.

net statistics server
net statistics workstation

net stats server
net stats workstation

net stats srv | find "Statistics"


Thursday, March 13, 2014

www.blogger.com is one of the widely known, Google’s hosted blogging platform, which also allow you to make money from the ads if your site mange to find a large enough audience to make it worthwhile. The default domain name provided by blogger is of pattern myblog.blogspot.com.  The best part with blogger is it will allow you to use your custom domain name and help you to brand your product. You can find a lot of articles which provide you the necessary information to use custom domain name for your blog with different domain provider.

This article mainly focuses on creating your custom domain with ohodomain.com  domain provider. When you purchase a domain from ohodomain.com,they assign an IP address (A record and CNAME record) for the domain. Hence, you need to change those records to point to your Blogger.com blog. This post can help you to change the A and CNAME records of your OhoDomain account.

The overall process include following steps:
1. Purchase a domain name from shop.ohodomain.com.
2. Create a domain in www.blogger.com.
3. Create A-record and CNAME entry in ohodomain.com

1. Purchase a domain name from shop.ohodomain.com
Process is very straight forward, go to the shop.ohodomain.com, register and purchase a domain name you wish to desire. Currently they accept e-sewa, NIBL and Paypal online payment method. If you want to purchase domain from Nepal, e-sewa and NIBL payment is the best option.

2. Create a domain in www.blogger.com.
Now go to the blogger.com, if you already have google account (One account. All of google, ya that's their motto.) no need to signup otherwise you have to create a google account. Once register create a blog from blogger dashboard.


Click on "New Blog" to create a blog


Now go to settings page of newly created blog.


Click on "Add custom domain" to point your "googlecustomblog.blogspot.com" to www.customdomain.com. Google will suggest you to create two CNAMEs entry on your domain registrar's

3. Create A-record and CNAME entry in ohodomain.com. Log on to ohodomain.com and search for domain you have created.

Click on "DNS Management" menu and finally click on "Manage DNS" section, where you can create A-record entry and CNAMEs entry.

ghs.google.com is same for all domain while second CNAMEs is different for each domain.
C-NAMEs
Enter your domain name in the format customdomain.com, and list the I.P. addresses shown below in the "A" section. You'll need to create four separate A-records which point to four different Google IPs.
216.239.32.21
216.239.34.21
216.239.36.21
216.239.38.21

A-Record

One last steps go to blogger setting page again and redirect customdomain.com to www.customdomain.com otherwise visitors who leave off the "www" will see an error page.


That's it you have done, obviously it took some times or may be 1-2 days to complete the whole process. 

Friday, February 28, 2014

Android Application Testing can be performed with two basic functionality of testing i.e Manual and Automation Testing.

Well, Android Application for manual testing there is always the Android Virtual Device (AVD) tool. It should be easily accessible from IDE. Otherwise, we have to buy an Android-enabled device and fingers should be used. Android Application testing is done with different aspects as there is type with native and web application testing. First the android application should be install in the device or Android virtual Devices.We go through the functionality, usability and consistency for any android application that we build up. The aim of our testing is to make application bug free so we should understand the bug detection saves a huge amount of resources and reduces the maintenance costs. This is the best known reason to write the software test for android application development project. As the witting the test gives deeper understating of requirement and the problem to be solved. The major part we have to be considering while manual testing in android application are:
Functional Testing:  We will go through the functional testing for android application to ensures that the application is working as per the requirements. Most of the test conducted for this is driven by the user interface and call flows. Functional Test will focus on validating that tasks/defects (as mentioned in Test Scope) have been implemented/fixed as expected. Test Scope define with the objective of test plan describes specifically what you want your testing to accomplish.
Regression Testing: Regression Test will be performed to ensure that the specific changes (enhancements/fixes as mentioned in Test Scope) have not adversely affected any other functionality. The purpose of regression testing in android application is to provide a general assurance that no additional errors were introduced in the process of fixing other problems. Regression testing is commonly used to test the system efficiently by systematically selecting the appropriate minimum suite of these needed to adequately cover the affected change. Common methods of regression testing include re executing previously run tests and checking whether previously fixed defects have re-emerged. The main reasons for regression testing in android application is that it’s often extremely difficult for a android programmer to figure out how a change in one part of the application will affect other parts of the application.

Unit Testing: Unit testing can be performed by the programmers to test the android application. Junit is the term used for the Unit Testing which is the de-facto standard. It performs the test object in isolation and in a repeatable way. It is usually rely on mock objects. The goal of nit testing is to isolate each part of the program and show that the individual parts are correct .A unit test provides a strict, written contract that the piece of code must satisfy. As a result, it affords several benefits. Unit tests find problems early in the development cycle.

Version Compatibility Testing: Version compatibility test, comprising of a non-exhaustive set of tests that aim at ensuring that it works in the different Android Version, will be executed as soon as a new build in QA Environment is received. The purpose of this test is to verify whether the build is stable for different Android Versions.

Performance Testing: Performance testing should be done to measure the performance of android application in a repeatable way. When testing the performance if it cannot be measurable then application cannot be improved. We should focus towards the premature optimization which does more harm than good. Android Application can be tested with the different devices or AVD emulator. It depends upon the hardware part of the devices. As to the better system it will provide the best performance and to the least it will be minor.

Security Testing: Security testing in android application is very important that it should follow all the security objectives. They are confidentiality, Integrity, Authentication, Authorization, Availability, etc.

Integration Testing: Integration testing defines how the components work together in android application. We have to ensure that modules have been unit tested for android components which needs integration with the system. Many testing framework facilitates the integration during the android application testing.

The purpose of integration testing is to verify functional, performance, and reliability requirements placed on major design items. These “ design items”, or groups of units , are exercised through their interfaces using black box testing , success and error access being simulated via appropriate parameter and data inputs.

Usability Testing: Usability testing is carried out to verify if the application is achieving its goals and getting a favorable response from users. This is important as the usability of an application is its key to commercial success. This testing is more feasible during the User Acceptance Testing.

Others:

Memory Leakage Testing: This testing is done to find that how much memory is being used by android application in devices. It is dependent to the performance and size of the application. If the size of application is higher it will take more memory in the application. Though we should test the total memory allocation by application in the devices to prevent from memory leakage.


What to Test

Testing Android Application is challenging for the tester one should have good knowledge of software testing process. There are some ideas for testing which should be in the priority before testing android application. These are the external part of testing as we have discussed all the testing process above. Some of the ideas for testing are as follows:

  • Change in orientation
  • Change in configuration
  •  Battery life
  •  Dependence on external source

Key Challenges in Android Application Testing


  • Variety of Mobile Devices - Mobile devices differ in screen sizes, input methods (QWERTY, touch, normal) with different hardware capabilities.
  •  Different Resolution – Android application should be applicable to different resolutions of devices. One can used the android devices for the feasible we can test in avd emulator by making different resolution of emulator. There is diversity in Mobile Platform/OS so testing a single application across multiple devices running on the same platform and every platform poses a unique challenge for testers.
  •  Scripting - While testing the android application there may be the variety of devices which makes executing the test script (Scripting) a key challenge. As devices differ in keystrokes, input methods, menu structure and display properties single script does not function on every device.

Test Automation


Android Application testing integrates with the JUnit framework and based with JVM and for testing which required Android System. Android framework is an important part of the development environment which provides and architecture and powerful tools that help to test every aspect of application at every level from unit to framework. Some of automated testing frameworks or tools for Android Applications are including not limited to Activity Instrumentation, Selenium WebDriver2.0, MonkeyRunner, Robotium, or Roboelectric. Android has basic support for instrumentation tests, one of the possibilities being the Activity Instrumentation Test Case class belonging to the android.test package and extending JUnit’s Test Case in order to provide functional testing of Android activities. When an application is tested, each instrumented activity is launched inside the Virtual Machine on and Android emulator or an actual android device. 


What can we test?
  • Classes
  • User Interface
  • Services
  • Content Providers etc

The major return back of Android frameworks supports followings:

  • Android Test suites are based on JUnit. You can use plain JUnit to test a class that doesn’t call the android API, or Android’s JUnit extensions to test android components.
  • The Android JUnit extensions provide component-specific test case classes. These classes provide helper methods for creating mock objects and methods that help you control the lifecycle of a component.
  • Test suites are contained in test packages that are similar to main application packages, so you don't need to learn a new set of tools or techniques for designing and building tests.
  • The SDK tools for building and tests are available in Eclipse with ADT, and also in command-line form for use with other IDEs. These tools get information from the project of the application under test and use this information to automatically create the build files, manifest file, and directory structure for the test package.
  • The SDK also provides monkey runner, an API for testing devices with Python programs, and UI/application Exercise Monkey, a command-line tool for stress-testing UIs by sending pseudo-random events to a device.
The above points describes the fundamentals of the Android testing framework, including the structure of tests, the APIs that you use to develop tests, and the tools that you use to run tests and view results. 

The following diagram summarizes the testing framework: 





Figure 1.0

Test Structure: Android's build and test tools assume that test projects are organized into a standard structure of tests, test case classes, test packages, and test projects. Android testing is based on JUnit. In general, a JUnit test is a method whose statements test a part of the application under test. You organize test methods into classes called test cases (or test suites). Each test is an isolated test of an individual module in the application under test. Each class is a container for related test methods, although it often provides helper methods as well. In JUnit, you build one or more test source files into a class file. Similarly, in Android you use the SDK's build tools to build one or more test source files into class files in an Android test package. In JUnit, you use a test runner to execute test classes. In Android, you use test tools to load the test package and the application under test, and the tools then execute an Android-specific test runner.


Test Project: Tests, like Android applications, are organized into projects. A test project is a directory or Eclipse project in which you create the source code, manifest file, and other files for a test package. The Android SDK contains tools for Eclipse with ADT and for the command line that creates and updates test projects for you. The tools create the directories you use for source code and resources and the manifest file for the test package. The command-line tools also create the Ant build files you need.

The testing API for android testing are as follows:

  •  JUnit
  •   Instrumentation
  •  Test case classes
  •   AndroidTestCase
  •   ApplicationTestCase
  •   InstrumentationTestCase
  •   Assertion classes
  •   Mock object classes
  •   Simple mock object classes
  •    Resolver mock objects



Key Classes for testing framework are as follows:

  •   Instrumentation TestRunner
  •   Android.test
  •   Android.test.mock
  •  Junit.framework

Activity Testing:

Activity testing is partially dependent on the Android instrumentation framework. It consists of components, activities which have a complex life cycle based on cal back methods; these can’t’ be invoked directly except by instrumentation. More often we can test the activity of android application by using instrumentation and other test facilities. Activity will not participate in the normal interactions with the system. And some methods should be avoided and will throw the exceptions if called. We can perform the Automation Testing with the help of Activity testing tools. There are methods, classes and activity packages which we will use to create the simple android application for testing.


UI Test:

The final stage of testing is to verify that UI of application. Your special consideration should be taken if your tests involve UI components. As you may have already known, only the main thread is allowed to alter the UI in Android. Thus a special annotation @UIThreadTest is used to indicate that particular test should be run on that thread and would have the ability to alter the UI. On the other hand, if you only want to run parts of your test on the UI thread, you may use the Activity.runOnUIThread(Runnable r) method providing the corresponding runnable containing testing instructions.


A helper class TouchUtils is also provided to aid in the UI test creation allowing the generation of events to send to the views, such as:

  • Click
  • Drag
  •  Long click
  •  Scroll
  • Tap
  • Touch

Service Testing:

To test a service you use the ServiceTestCase class. It provides the startService() and bindService() methods to interact with the service. The bindService) return immediately a IBinder object without callback. Testing asynchronous processing in services is a challenge as the duration of this processing may vary. It is good practice to test if the service handles correctly multiple calls from startService(). Only the first call of startService() triggers the onCreate() of the service but all calls trigger a call to onStartCommand() of the service.








Saturday, February 22, 2014

Selenium is a portable software testing framework for web applications. Selenium provides a record/playback tool for authoring tests without learning a test scripting language. Selenium provides a test domain specific language (DSL) to write tests in a number of popular programming languages including C#, Java, Groovy, Perl, PHP, Python and Ruby. Test playback is possible in most modern web browsers. Selenium deploys on Windows, Linux, and Macintosh platforms.
Selenium IDE is an integrated development environment for Selenium scripts. It is implemented as a Firefox extension, and allows you to record, edit, and debug tests. Selenium IDE includes the entire Selenium Core, allowing you to easily and quickly record and play back tests in the actual environment that they will run.
Selenium IDE is not only a recording tool: it is a complete IDE. You can choose to use its recording capability, or you may edit your scripts by hand. With auto complete support and the ability to move commands around quickly, Selenium IDE is the ideal environment for creating Selenium tests no matter what style of tests you prefer.
Selenium Remote Control (RC) is a test tool that allows you to write automated web application UI tests in any programming language against any HTTP website using any mainstream JavaScript-enabled browser.
Selenium RC comes in two parts. 
1.      A server which automatically launches and kills browsers, and acts as a HTTP proxy for web requests from them.
2.      Client libraries for your favourite computer language.
The RC server also bundles Selenium Core and automatically loads it into the browser.
Below is a simplified architectural representation...


PHPUnit is a regression testing framework used by the developer who implements unit tests in PHP.

·         Downloading and Installing
 1.)  Selenium IDE
For use with Firefox, download the IDE from the Selenium downloads page (http://seleniumhq.org/download/).  Then install the Selenium-IDE add-on on your Firefox browser. After the installation completes you can run the IDE to create test cases. To run the Selenium-IDE, simply select it from the Firefox Tools menu. It opens with an empty script-editing window and a menu for loading, or creating new test cases.

2.)  Selenium RC

- Make sure that you have Java Runtime installed on your machine.
- Download Selenium RC from downloads page (http://selenium-rc.seleniumhq.org/download.html)
- After extracting the files from the archive, copy the 'selenium-server.jar' file to any location of your choice.
- Start the Selenium RC server from the command-line by issuing the following command:   java -jar selenium-server.jar
This will start the server on port 4444.
- Now the server is ready to accept test commands from your PHP script. Make sure you keep this server running till you finish testing.




3.) PHPUnit
-An easy way to install PHPUnit is to use the PEAR installer. First of all install the latest version of PEAR by supplying following command :
pear install PEAR-1.9.2
 -The PEAR channel (pear.phpunit.de) is used to distribute PHPUnit so make sure that it is registered with your local PEAR environment:
pear channel-discover pear.phpunit.de
-After the channel is registered install PHPUnit:
pear install phpunit/PHPUnit
-Finally upgrade the PHPUnit to its latest version.
pear upgrade phpunit/PHPUnit

·         Running a simple test using Selenium IDE
-Start Selenium IDE in Firefox: Tools->Selenium IDE
-Click on the red record button on the right.
- Browse to http://www.deerwalk.com
- Browse the page and all the links and buttons you clicked will be recorded.
-  Stop the recording by clicking on the record button.
If you click on the ‘Source’ tab of the IDE you can see the test.html generated by selenium.
The ‘table’ tab shows the commands recorded by Selenium.
- Open a new tab in Firefox and click on the Selenium IDE’s play button to run the recorded test.


- The IDE should play your recorded test. The IDE after the test run is shown below. In the ‘Log section’ you can see the various events run by the test. In the table tab you can see that all the rows are green, which means that the test ran successfully.





The interesting part follows – running the same test from PHP. From the file menu, select ‘Export Test Case As…’ and as we are using PHP, select ‘PHP – PHPUnit’. Save the file by the name ‘Example.php’.





This is what we get in Example.php
<?php
class Example extends PHPUnit_Extensions_SeleniumTestCase
{
  protected function setUp()
  {
    $this->setBrowser("*chrome");
    $this->setBrowserUrl("http://www.testurl.com/");
  }

  public function testMyTestCase()
  {
    $this->open("/");
    $this->click("link=Services »");
    $this->waitForPageToLoad("30000");
    $this->click("link=Careers »");
    $this->waitForPageToLoad("30000");
    $this->click("link=Blog");
    $this->waitForPageToLoad("30000");
    $this->click("link=Case Studies");
    $this->waitForPageToLoad("30000");
  }
}
?>






·         Actual testing
Now that PHPUnit is installed and the Selenium RC server is up and running, it’s time to run our test we saved before in our ‘Example.php’ file. Type the following on the command-line:
                        phpunit Example
This will start the test. The PHPUnit Selenium driver will execute each test command from your file and send it to the Selenium server, which does the job of launching the appropriate browser, opening web pages, and performing various specified actions; and closing the browser after the test completes.


Now to test the same test case in another browser you simply need to set Browser to the one you want the test to run.

Supported browsers include:

  *firefox
  *mock
  *firefoxproxy
  *pifirefox
  *chrome
  *iexploreproxy
  *iexplore
  *firefox3
  *safariproxy
  *googlechrome
  *konqueror
  *firefox2
  *safari
  *piiexplore
  *firefoxchrome
  *opera
  *iehta
  *custom




·         “Selenese” Selenium Commands
A command is what tells Selenium what to do. Selenium commands come in three 'flavors': Actions, Accessors and Assertions.
Actions are commands that generally manipulate the state of the application. They do things like "click this link" and "select that option". If an Action fails, or has an error, the execution of the current test is stopped.
Many Actions can be called with the "AndWait" suffix, e.g. "clickAndWait". This suffix tells Selenium that the action will cause the browser to make a call to the server, and that Selenium should wait for a new page to load.
Accessors examine the state of the application and store the results in variables, e.g. "storeTitle". They are also used to automatically generate Assertions.
Assertions are like Accessors, but they verify that the state of the application conforms to what is expected. Examples include "make sure the page title is X" and "verify that this checkbox is checked".
All Selenium Assertions can be used in 3 modes: "assert", "verify", and "waitFor". For example, you can "assertText", "verifyText" and "waitForText". When an "assert" fails, the test is aborted. When a "verify" fails, the test will continue execution, logging the failure. This allows a single "assert" to ensure that the application is on the correct page, followed by a bunch of "verify" assertions to test form field values, labels, etc. "waitFor" commands wait for some condition to become true (which can be useful for testing Ajax applications). They will succeed immediately if the condition is already true. However, they will fail and halt the test if the condition does not become true within the current timeout setting.

·         Commonly Used Selenese
-open
    opens a page using a URL.
-click/clickAndWait
    performs a click operation, and optionally waits for a new page to load.
-verifyTitle/assertTitle
    verifies an expected page title.
-verifyTextPresent
    verifies expected text is somewhere on the page.
-verifyElementPresent
    verifies an expected UI element, as defined by its HTML tag, is present on the page.
-verifyText
    verifies expected text and it’s corresponding HTML tag are present on the page.
-verifyTable
    verifies a table’s expected contents.
-waitForPageToLoad
    pauses execution until an expected new page loads. Called automatically when clickAndWait is used.
-waitForElementPresent
    pauses execution until an expected UI element, as defined by its HTML tag, is present on the page.



Categories

.
Powered by Blogger.

Popular Posts

Like Us