Showing posts with label Test Data. Show all posts
Showing posts with label Test Data. Show all posts

Thursday, June 11, 2020

Generate filename with date time stamp and separate file name and path from given file path

Hi folks,

many times we need to create the dummy or new file or report file with date timestamp appending to file name. Also, from the given file path we need to separate the file name and file path then definitely this post might help you.

Public Function AddResultTestdatafile(strFilePath)
   
    Workbooks.Add Template:=strFilePath
    strNewFileTempName = getFName(strFilePath)
    strTestFileNameval = Split(strNewFileTempName, ".")
    strNewFilePath = getPath(strFilePath)
    'to generate file name appending datetime stamp
    strNewTestFileName = strTestFileNameval(0) & "_" & "DummyData" & "_" & Year(Date) & Right("00" & Month(Date), 2) & Right("00" & Day(Date), 2) & Right("00" & Hour(Time), 2) & Right("00" & Minute(Time), 2) & Right("00" & Second(Time), 2) & ".xlsx"
    ActiveWorkbook.SaveAs _
        Filename:=strNewFilePath & strNewTestFileName
    ResultDummyFilename = strNewFilePath & strNewTestFileName
    AddResultTestdatafile = ResultDummyFilename
   
End Function

'to get the path from given file path
Function getPath(pathfile) As String: getPath = Left(pathfile, InStrRev(pathfile, "\")): End Function

'to get the file name from given file path
Function getFName(pathfile) As String: getFName = Mid(pathfile, InStrRev(pathfile, "\") + 1): End Function

Cheers.
TJ

Wednesday, December 19, 2018

Test Complete / UFT-Run functions dynemic through excel files

Hey folks,

sometimes functions execution flow needs to controll through excel files and need to run the functions dynemic, so hope this line of code will help. Same applies to UFT as well.

in excel sheet, for exampme TC1 having FUNC1-10 then,

for fncnt=1 to sheet. columncount
    strfunctionname=""
    if(aqconvert. vartostr(fncnt)) <>"" then
         strfunctionname=aqconvert. vartostr(testcasedriver. value(fncnt))
        functiontorun="Call" & strfunctionname
       execute functiontorun
    end if
next

wishes,
Trupti

Tuesday, December 18, 2018

Send Email through vbs using CDO object

set  objemail=createobject("cdo. message")
objemail. from=strmailfrom
objemail. to=strmailto
objemail. subject=strmailsubject
objemail. textbody=strmailbody
strmailattachment="c:\test. btml"
objemail. addattachment strmailattachment
objemail. configuration. fields. item("http://schemas.microsoft.com/cdo/configuration/sendusing")=2
objemail. configuration. fields. item("http://schemas.microsoft.com/cdo/configuration/smtpserver") ="mailhost. ldn... com"
objemail. configuration. fields. item("http://schemas.microsoft.com/cdo/configuration/smtpserverport") =25
objemail. configuration. fields. update
objemail. send

Send email through vbs using Outlook Application utility object

set objoutlookmail=createobject("outlook. application")
Set mymail=objoutlookmail. createitem(0)
mymail.display
set mymailproperty=objoutlookmail. activeinsepector
if mymailproperty. iswordmail="trur" then
    set mydoc=mymailproperty. wordeditor
    mydoc. range chr(13)+"Hi All," +chr(13) & " Please see execution status for.... application." +chr(13)
     mydoc.range.insertafter chr(13)+"Regards,"+chr(13) & "support team" +chr(13)
     strmailattachment="c:\test. html"
      mymail. Attachments. add strmailattachment
       mymail. from="abc@gmail.com"
       mymail. to="xyz@gmail.com;pyz@gmail.com"
      mymail. subject="Application Automation Execution Reports"
       mymail. send
end if
Set mymail.=Nothing
Set mydoc=Nothing
Set objoutlookmail=Nothing

Thursday, August 2, 2018

Text file edit using UFT/QTP/VBS

Hi folks

Create test file on path with content.

Test file edit data-Trupti to Jethva
Data -Trupti

Save file c:\test.txt

Now write function as
Public function fnModifytextfile(strfilepath,strchangedata)
Const ForReading=1
Const ForWriting=2
Set objfso=createobject(“scripting.filesystemobject”)
Set myfile=objfso.opentextfile(strfilepath,forreading,true)
Set mytemp=objfso.opentextfile(strfilepath & “.tmp”, forwriting,true)
Do while not myfile.atendofstream
       Myline=myfile.readline
       If instr(myline,”Data”) then
            Orignaldata=split(myline,”-“)
            Orignaldatachange=orignaldata(1)
            Datatobechange=“ “& strchangedata
            Myline=replace(myline,orignaldatachange,datatobechange)
       Endif
       Mytemp. Writeline myline
Loop
Myfile.close
Mytemp.close
Objfso.deletefile(strfilepath )
Objfso.movefile strfilepath & “.tmp”, strfilepath
Msgbox “done”
End function
Call fnModifytextfile(“c:\test.txt”,”jethva”)

Thursday, March 10, 2011

Example of IPV6


Example of IPv6 address:
4FDE:0000:0000:0002:0022:F376:FF3B:AB3F

Whenever you want to give static IPv6 address then change the block# 5 of IPv6 with the last block of IPv4.

If you IPv4 address is : 40.40.40.155 then IPv6 address would be 4FDE:0000:0000:0002:0155:F376:FF3B:AB3F

Thursday, March 3, 2011

About Test Data


Hey folks,

It’s so long time, to write blog on testing field back. Here I try to cover all about test data.

Test Data
A set of data created for testing new or revised applications.
Test data should be developed by the user as well as the programmer, tester and must contain a sample of every category of valid data as well as many invalid conditions as possible
Tester should check and update the test data before execution of any test case

Why Required
If you are writing a Test case then you need input data for executing that test case. If you don’t have the systematic approach for building test data while writing and executing test cases then there are chances of missing some important test cases. Preparing proper test data is a core part of “project test environment setup”. Preparation of test data is part of preparing a Test bed activity. Tester cannot pass the bug responsibility saying that complete data was not available for testing. Tester should create his/her own test data additional to the existing standard production data. Your test data set should be ideal in terms of cost and time.

Format of Test Data
The test data may be any kind of input to application, any kind of file that is loaded by the application or entries read from the database tables. It may be in any format like xml test data, system test data, SQL test data or stress test data.

Tips For Test Data
1.       Good practice for every tester keep/make their own set of test data. Sometimes on same build many testers work, so they have same access on the test data files and change the data as per their requirement. So better, keep a personal copy of your own data. It may be of any format like inputs to be provided to the application, input files such as word file, excel file or other photo files
2.       Always keep your test data up to date. Sometimes, test data is not updated so long times.
3.       Before filing the bug, please make sure that your existing test data is not corrupted for executing the test case on application.
4.       Try to make test data as per real time use of application
5.       Test data can be said to be ideal if for the minimum size of data set all the application errors get identified.
6.       Try to prepare test data that will incorporate all application functionality, but not exceeding cost and time constraint for preparing test data and running tests.

How to prepare test data that will ensure complete test coverage?
Design your test data considering following categories:
1.       No data: Run your test cases on blank or default data. See if proper error messages are generated.
2.       Valid data set: Create it to check if application is functioning as per requirements and valid input data is properly saved in database or files.
3.  Invalid data set: Prepare invalid data set to check application behavior for negative values, alphanumeric string inputs.
    • Illegal data format: Make one data set of illegal data format. System should not accept data in invalid or illegal format. Also check proper error messages are generated.
    • Boundary Condition data set: Data set containing out of range data. Identify application boundary cases and prepare data set that will cover lower as well as upper boundary conditions.
    • Data set for performance, load and stress testing: This data set should be large in volume.
    • This way creating separate data sets for each test condition will ensure complete test coverage.
In this article, I took the help from one stop testing site, As I can gather all the information at one place at time, I use some of the part from there

Thursday, June 3, 2010

Online Test Data generation

@Friends,

When I was working with web application testing, at that time, my manager came and told me that you have to prepare test data for our application. At that time, I was intermediate level tester in documentation part, so I was thinking, how I would do that and all. I searched lots of and at that time, I went through some good sites to generate test data. So I would like to share that information with you guys.

http://www.generatedata.com/#about

http://www.turbodata.ca/

Monday, April 19, 2010

Bulk Insert Query useful for Test Data


Bulk insert Query
To bulk upload data from csv to sql tables, import csv file to sql table or load comma deliminated file into sql, use BULK INSERT query. This is very useful when you want to insert test data from csv files to sql.
Follow below steps.
  • Create database with TestDatabase
  • Create table with CSVTest using below query
  • Create csvtest.txt file in C:
  • If your database server is local then file keep in local C:
  • If your database server is remote then file keep in remote database server’s C:
  • Value of txt file should be in order of your table structure (refer example)
  • Run bulk insert query
  • Verify content of your table
--use current database
use TestDatabase
--create csvtest table with fields
GO
CREATE TABLE CSVTest
(ID INT,
FirstName VARCHAR(40),
LastName VARCHAR(40),
BirthDate SMALLDATETIME)
GO
-- create csvtest.txt file in c:\csvtest.txt with
1,James,Smith,19750101
2,Meggie,Smith,19790122
3,Robert,Smith,20071101
4,Alex,Smith,20040202
--bulk insert query from text file
BULK
INSERT dbo.CSVTest
FROM 'c:\test.txt'
WITH
(
FIELDTERMINATOR = ',',
ROWTERMINATOR = '\n'
)
GO
--Check the content of the table.
SELECT *
FROM CSVTest
GO