Saturday, October 27, 2007

Interesting Java puzzles

I came across a set of interesting java puzzles... Do share your views/results on these.

  1. public class StringTest
    {
    public static void main(String[] args){
    foo();
    bar();
    }
    public static void foo(){
    String s = "str4";
    String s1 = "str" + s.length();
    System.out.println("(s==s1) = " + (s1==s));
    }
    public static void bar(){
    String s = "str4";
    String s1 = "str" + "4";
    System.out.println("(s==s1) = " + (s1==s));
    }
    }

  2. public class Assignment {
    public static void main(String[] a){
    int count = 0;
    for (int i = 0; i < 3; i++)
    count += count++;
    System.out.println(count);
    }
    }

  3. class StaticTest {
    static { initIfNecessary(); }

    private static int sum;

    public static int getSum() {
    initIfNecessary();
    return sum;
    }

    private static boolean initialized = false;

    private static synchronized void initIfNecessary() {
    if (!initialized) {
    for (int i = 0; i < 100; i++)
    sum += i;
    initialized = true;
    }
    }
    public static void main(String[] args) {
    System.out.println(getSum());
    }
    }

  4. package click;
    public class CodeTalk {
    public void doIt() { printMessage(); }
    void printMessage() { System.out.println("Click"); }
    }
    ------------------
    package hack;
    import click.CodeTalk;
    public class TypeIt {
    private static class ClickIt extends CodeTalk {
    void printMessage() { System.out.println("Hack"); }
    }
    public static void main(String[] args) {
    new ClickIt().doIt();
    }
    }


  5. public class Lazy {
    private static boolean initialized = false;
    static {
    Thread t = new Thread(new Runnable() {
    public void run() {
    initialized = true;
    }
    });
    t. start();
    try {
    t.join();
    } catch (InterruptedException e) {
    throw e.printStackTrace();
    }
    }

    public static void main(String[] args) {
    System.out.println(initialized);
    }
    }
 

Wednesday, October 17, 2007

WinRunner Questions... 1

Winrunner is Automation Test Tool for Software Testing. Here are some of the most frequently asked Questions and their Answers on Winrunner.

WinRunner testing process?

WinRunner testing process involves six main stages

  • Create GUI Map File so that WinRunner can recognize the GUI objects in the application being tested
  • Create test scripts by recording, programming, or a combination of both. While recording tests, insert checkpoints where you want to check the response of the application being tested.
  • Debug Test: run tests in Debug mode to make sure they run smoothly
  • Run Tests: run tests in Verify mode to test your application.
  • View Results: determines the success or failure of the tests.
  • Report Defects: If a test run fails due to a defect in the application being tested, you can report information about the defect directly from the Test Results window.

What is contained in the GUI map?
WinRunner stores information it learns about a window or object in a GUI Map. When WinRunner runs a test, it uses the GUI map to locate objects. It reads an object’s description in the GUI map and then looks for an object with the same properties in the application being tested. Each of these objects in the GUI Map file will be having a logical name and a physical description.

There are 2 types of GUI Map files.

  • Global GUI Map file: a single GUI Map file for the entire application
  • GUI Map File per Test: WinRunner automatically creates a GUI Map file for each test created.

How does WinRunner recognize objects on the application?
WinRunner uses the GUI Map file to recognize objects on the application. When WinRunner runs a test, it uses the GUI map to locate objects. It reads an object’s description in the GUI map and then looks for an object with the same properties in the application being tested.

How does WinRunner evaluates test results?
Following each test run, WinRunner displays the results in a report. The report details all the major events that occurred during the run, such as checkpoints, error messages, system messages, or user messages. If mismatches are detected at checkpoints during the test run, you can view the expected results and the actual results from the Test Results window.

What is contained in the test scripts?
The test scripts contain the statement in Mercury Interactive’s Test Script Language (TSL). These statements appear as a test script in a test window. You can then enhance your recorded test script, either by typing in additional TSL functions and programming elements or by using WinRunner’s visual programming tool, the Function Generator.