Friday 9 March 2012

To connect a database and get the records from database


Set cnn = CreateObject("ADODB.Connection")
   cnn.ConnectionString = "driver={SQL Server};server=<enterserver>;" & _
      "uid=<enterlogon>;pwd=<enterpassword>;database=<enterdatabase>"
   cnn.Open
   If cnn.State = adStateOpen Then
      cnnState = "open"
   Else
      cnnState = "closed"
   End If
set rs=createobject("adodb.recordset")
mySql = "Select * from Tab_name"
rs.open sql,cnn
' To print all the column names
for i=0 to rs.fields.count-1
print rs.fields(i).name
Next
'to print all the values for each column
for i=0 to rs.fields.count-1
Print rs.Fields(i).value
rs.moveNext
Next
'close the connection
cnn.Close
cnnState = "closed"

Design Phase Testing




TESTING DURING THE DESIGN STAGES
No code has been written yet, so we're still testing ideas. These ideas are more formally expressed and more detailed than the original plans. Examining the design documents, reviewers should develop a clear picture of how the system will work if it's built according to the design. Testers may not be included in these reviews, but they will be valuable for your test planning, so try to find time for them. (But don't speak in review meetings unless you have something valuable to say.) The reviewers should explore the following issues:
  • Is the design good? Will it lead to an efficient, compact, testable, maintainable, product?
  • Does the design meet the requirements? If the planning documents are informal, changeable, and ambiguous, the design will be the first formal statement of the product requirements. Management and marketing staff should review the design as such, not just as a design.
  • Is the design complete? Does it specify all relationships between modules, how they pass data, what happens in exceptional circumstances, what starting state should be assumed for each module, and how that state will be guaranteed?
  • Is the design possible? Can the machine run this quickly? Is there enough memory? Are there enough I/O devices? Can data be retrieved this quickly from a database? Can this version of the development language do the things you're trying to do?
  • How well does the design cover error handling? Especially when doing top-down design, it's easy to think of error paths as "details," to be dealt with "later." All too often, by the time "later" rolls around, these "details" have been forgotten. Along with checking that all remotely plausible error conditions are dealt with in the design, it is also important to ask whether a given error is handled at the right level. For example, if an error detected in one module forces backtracking and cancellation or correction of work done in other(s), the error should probably be handled in the higher-level module that calls all the affected modules.


Requirements Phase Testing

TESTING DURING THE REQUIREMENTS STAGES
Ideas are tested now, not code. The "testers" (reviewers) include marketers, product managers, senior designers, and human factors analysts. Members of the Testing Group are rarely involved at this stage. (See Chapter 13 for useful planning-stage tasks for testers.)
The reviewers read drafts of the planning documents. Then they gather data, using comparative product evaluations, focus groups, or task analyses. These arc commonly described as planning and design tools, but they are also testing procedures: each can lead to a major overhaul of existing plans.
The reviewers should evaluate the requirements document (and the functional definition based on it) in terms of at least six issues:
  • Are these the "right" requirements? Is this the product that should be built?
  • Are they complete? Does Release 1 need more functions? Can some of the listed requirements be dropped?
  • Are they compatible? Requirements can be logically incompatible (i.e., contradictory) or psycho logically incompatible. Some features spring from such different conceptualizations of the product that if the user understands one of them, she probably won't understand the other(s).
  • Are they achievable? Do they assume that the hardware works more quickly than it does? Do they require too much memory, too many I/O devices, too fine a resolution of input or output devices?
  • Are they reasonable? There are tradeoffs between development speed, development cost, product performance, reliability, and memory usage. Are these recognized or do the requirements ask for lightning speed, zero defects, 6 bytes of storage, and completion by tomorrow afternoon? Any of these might be individually achievable, but not all at once, for the same product. Is the need for a priority scheme recognized?
  • Are they testable? How easy will it be to tell whether the design documents match the requirements? 

Test to choose cheapest flight for inset order

the below program will work to chose cheapest flight
Add the objects to the test before  executing this code

Window("Flight Reservation").Activate
Window("Flight Reservation").WinObject("Date of Flight:").Type "121212"
Window("Flight Reservation").WinComboBox("Fly From:").Select "Denver"
Window("Flight Reservation").WinComboBox("Fly To:").Select "Frankfurt"
Window("Flight Reservation").WinButton("FLIGHT").Click

FlightCount = Window("Flight Reservation").Dialog("Flights Table").WinList("From").GetItemsCount()
FlightDetails = Window("Flight Reservation").Dialog("Flights Table").WinList("From").GetItem(0)
'msgbox FlightDetails

flights = split(FlightDetails,"$")
TempPrice = flights(1)
flight=0
For i=0 to FlightCount-1
FlightDetails = Window("Flight Reservation").Dialog("Flights Table").WinList("From").GetItem(i)
'msgbox FlightDetails
flights = split(FlightDetails,"$")
price = flights(1)

If Price<=Tempprice Then
flight = i

End If
'msgbox flight
Next
FlightDetails = Window("Flight Reservation").Dialog("Flights Table").WinList("From").Select(flight)
Window("Flight Reservation").Dialog("Flights Table").WinButton("OK").Click
msgbox FlightCount&" "&FlightDetails
Window("Flight Reservation").WinEdit("Name:").Set "test"
Window("Flight Reservation").WinButton("Insert Order").Click
Window("Flight Reservation").Activate
Window("Flight Reservation").Restore
Window("Flight Reservation").WinObject("Insert Done").Check CheckPoint("Insert Done")