You are reading the article Cyclomatic Complexity In Software Testing (Example) updated in March 2024 on the website Moimoishop.com. We hope that the information we have shared is helpful to you. If you find the content interesting and meaningful, please share it with your friends and continue to follow and support us for the latest updates. Suggested April 2024 Cyclomatic Complexity In Software Testing (Example)What is McCabe’s Cyclomatic Complexity?
Cyclomatic Complexity in Software Testing is a testing metric used for measuring the complexity of a software program. It is a quantitative measure of independent paths in the source code of a software program. Cyclomatic complexity can be calculated by using control flow graphs or with respect to functions, modules, methods or classes within a software program.
Independent path is defined as a path that has at least one edge which has not been traversed before in any other paths.
This metric was developed by Thomas J. McCabe in 1976 and it is based on a control flow representation of the program. Control flow depicts a program as a graph which consists of Nodes and Edges.
In the graph, Nodes represent processing tasks while edges represent control flow between the nodes.
Flow graph notation for a program:
Flow Graph notation for a program defines several nodes connected through the edges. Below are Flow diagrams for statements like if-else, While, until and normal sequence of flow.
How to Calculate Cyclomatic Complexity
Mathematically, it is set of independent paths through the graph diagram. The Code complexity of the program can be defined using the formula –V(G) = E - N + 2
E – Number of edges
N – Number of NodesV (G) = P + 1
Where P = Number of predicate nodes (node that contains condition)
Example –i = 0; n=4; while (i<n-1) do j = i + 1; while (j<n) do if A[i]<A[j] then swap(A[i], A[j]); end do; j=j+1; end do;
Flow graph for this program will be
V(G) = 9 – 7 + 2 = 4
V(G) = 3 + 1 = 4 (Condition nodes are 1,2 and 3 nodes)
Basis Set – A set of possible execution path of a program
1, 2, 6, 1, 7
1, 2, 3, 4, 5, 2, 6, 1, 7
1, 2, 3, 5, 2, 6, 1, 7Properties of Cyclomatic complexity:
Following are the properties of Cyclomatic complexity:
V (G) is the maximum number of independent paths in the graph
G will have one path if V (G) = 1
Minimize complexity to 10How this metric is useful for software testing?
Basis Path testing is one of White box technique and it guarantees to execute atleast one statement during testing. It checks each linearly independent path through the program, which means number test cases, will be equivalent to the cyclomatic complexity of the program.
This metric is useful because of properties of Cyclomatic complexity (M) –
M can be number of test cases to achieve branch coverage (Upper Bound)
M can be number of paths through the graphs. (Lower Bound)
Consider this example –If (Condition 1) Statement 1 Else Statement 2 If (Condition 2) Statement 3 Else Statement 4
Cyclomatic Complexity for this program will be 8-7+2=3.
As complexity has calculated as 3, three test cases are necessary to the complete path coverage for the above example.Steps to be followed:
The following steps should be followed for computing Cyclomatic complexity and test cases design.
Step 1 – Construction of graph with nodes and edges from the code
Step 2 – Identification of independent paths
Step 3 – Cyclomatic Complexity Calculation
Step 4 – Design of Test Cases
Once the basic set is formed, TEST CASES should be written to execute all the paths.More on V (G):
Cyclomatic complexity can be calculated manually if the program is small. Automated tools need to be used if the program is very complex as this involves more flow graphs. Based on complexity number, team can conclude on the actions that need to be taken for measure.
Following table gives overview on the complexity number and corresponding meaning of v (G):
Complexity Number Meaning
Cost and Effort is less
Cost and effort is Medium
Cost and Effort are high
Very high Cost and EffortTools for Cyclomatic Complexity calculation:
Many tools are available for determining the complexity of the application. Some complexity calculation tools are used for specific technologies. Complexity can be found by the number of decision points in a program. The decision points are if, for, for-each, while, do, catch, case statements in a source code.
Examples of tools are
OCLint – Static code analyzer for C and Related Languages
Reflector Add In – Code metrics for .NET assemblies
GMetrics – Find metrics in Java related applicationsUses of Cyclomatic Complexity:
Cyclomatic Complexity can prove to be very helpful in
Helps developers and testers to determine independent path executions
Developers can assure that all the paths have been tested atleast once
Helps us to focus more on the uncovered paths
Improve code coverage in Software Engineering
Evaluate the risk associated with the application or program
Using these metrics early in the cycle reduces more risk of the programConclusion:
Cyclomatic Complexity is software metric useful for structured or White Box Testing. It is mainly used to evaluate complexity of a program. If the decision points are more, then complexity of the program is more. If program has high complexity number, then probability of error is high with increased time for maintenance and trouble shoot.
You're reading Cyclomatic Complexity In Software Testing (Example)
Businesses have become more complex than ever. Artificial intelligence and technology are making our lives easier and providing consumers with more and more choices, but on the other hand, they are also increasing the burden on businesses to perform better and better. There is no relaxation in the complex and dynamic business world. Software testing and digital marketing are the two critical points of discussion in today’s article. The digital market helps the company market its product offerings in the digital space, and software testing is another crucial part of this digital world. This digital world where we live, breathe, and survive was created by someone, and then there was a tester who tested the feasibility and working of the digital world before making it available to the masses.
In this article, we will be diving deep into the concepts of digital marketing and software testing and then providing the readers with a comparison between digital marketing and software testing to better analyze.The Concept of Software Testing
Software testing is the process of analyzing whether the software product is working as it is supposed to. It helps the developers understand if there are any bugs or performance issues. It also helps the company understand if there is any way to reduce the cost of software development. Testing is a separate part of development. The number of developers and testers is equal. It is a very crucial part of software development. Software testing can be done in the following ways by the company −
Acceptance testing − This helps the company in understanding whether the product is working the way it was intended to.
Integration testing − In this process of testing the company tries to understand if the software is working properly when it is integrated with different other applications for better usage and convenience. For example, when Grammarly (an application that helps the user in correcting grammatical errors in sentence formation) software is integrated with the Gmail account.
Unit testing − in this form of testing, the entire software product is divided into various subunits, and then these subunits are tested for bugs and performance issues.
Performance testing − This is the test in which the company tries to understand the performance of the product under different scenarios of pressure or workload. This helps the company understand the performance of the product in real-life scenarios.
Sanity testing − This is a surface-level form of testing. The tester verifies the working of the basic functions of the product.
Regression testing −This testing helps the company understand the performance of the product when new features are added or integrated into the existing product. This helps the company understand the performance of the product in future scenarios.
Stress testing − This is a form of testing that helps the company understand how much pressure the product can take. The tester generally keeps applying pressure or stress till the system crashes to understand the limits of the system.
Usability testing − This testing helps the company understand how well the software product performs throughout the entire journey. In simple words, the product helps the user complete the entire journey in one go, and there are various other forms of testing.The Concept of Digital Marketing
Social media marketing − it is marketing done through various social media platforms like Facebook, Instagram, LinkedIn, Hike, WhatsApp, Telegram, YouTube, and others.
Affiliate marketing – it is marketing done by famous people on social media platforms or in the digital world and by experts in a particular field. Here, the influencers or affiliate marketers try to convince the consumer to purchase a particular product and brand.
Search Engine Marketing or Paid Marketing −Techniques: Here, the company pays the browsing website to promote its content on the top of the SERP so that it can have more consumers and high website traffic.
Search Engine Optimization − Here the marketers focus on improving the ranking of the page or the website on the browsing site through various tips and tricks. It is an organic form of marketing.
Email Marketing − In this type of marketing, businesses send e-mails to customers about products, services, price offers, discounts, or warm greetings on special occasions and holidays.Comparison Between Software Testing and Digital Marketing
According to our analysis, the job of a software tester is more stable than the job of a digital marketer. We are not saying that digital marketing is an inferior proposition; it is just a risky proposition, and the reasons to support our claim are as follows −
Software testing was born the day software products started getting developed. It is not just an additional feature of business but is required in the working of a product and before launching the product in the mass market or delivering the product to clients. So software testing jobs are going to be there as long as software products are being developed.
Digital marketing is a replacement for traditional marketing channels, and there is a high chance that we will get a replacement for digital marketing as well in the future. What will be the future is beyond our comprehension, but we as human beings have understood that there are going to be modifications in everything that we do. Change is our only constant.
There are going to be new developments in the testing domain as well, and hence testers have to ensure that they are updated in the field. They should always learn the emerging text scenarios and improve their performance in the existing ones.
When worst comes to worst, the company will start laying off the digital marketing team rather than the software team because the testers are required to create the product for the company.
Software testing and digital marketing are two very different functions in the business world. Comparing them will provide the user and business with no rewards or benefits, but integrating them will ensure that businesses can perform well in this dynamic working environment. Integration of software testing and digital marketing will provide the company with an edge over its competitors and will also enrich the customer experience. It is time that we grow together.
Testing is a major step for the successful delivery of any application. On the basis of the level of execution of testing, we can classify testing into two categories − System Testing and Acceptance Testing. Read this article to learn more about system testing and acceptance testing and how they are different from each other.What is System Testing?
System Testing is a type of testing which is used to validate the functionality of a developed software product. It is also known as black box testing. This testing involves the behavioral as well as functional testing of the software product as per the documents provided for testing. System testing is generally performed by developers as well as testers.
System testing includes both the module basis testing and integration testing with multiple modules. System testing is generally executed after the development and before the delivery of the software product. Since the system testing is performed by a group of testers, thus it would contain more negative test cases. The system testing uses all the possible dummy inputs for testing purpose.What is Acceptance Testing?
Acceptance testing is a type of testing that validates if a developed software product meets the client’s requirements or not. It covers the testing of parameters provided by the client before development of the software product.
Acceptance testing is generally performed by testers as well as clients. Therefore, acceptance testing covers both alpha and beta testing. This testing is generally performed after the system testing and before the delivery of the software product. Unlike system testing, acceptance testing uses all the possible random values of the inputs for testing.Difference between System Testing and Acceptance Testing
The following are some basic differences between System Testing and Acceptance Testing −
System Testing is the testing which basically validates the functionality of product developed. Also this testing covers the behavioral as well as functional testing as per the document provided to the tester for testing.
Acceptance testing is the type of testing which is used to check whether the software meets the customer requirements or not. It basically covers the acceptance criteria provided by the client before development of product.
In general, System testing is done by developers as well as testers.
Acceptance testing is done by testers, stakeholders as well as clients.
System Testing covers the module basis testing as well as integration testing with multiple modules.
Acceptance testing covers alpha and beta testing which means it is done at both sides i.e. at the side of delivery as well as side of client.
Order of execution
System testing is generally done after development and before delivery of the product.
Acceptance testing is done after System testing and delivery of the product.
In System Testing since it is performed by group of testers, it would contain more negative test cases.
Acceptance Testing contains more of positive test cases
All the possible dummy inputs are used in System Testing.
In acceptance testing, all the possible random inputs are used.Conclusion
The most significant difference between the two types of testing is that System Testing covers the behavioral as well as functional testing of the product as per the document provided, whereas Acceptance Testing covers the acceptance criteria provided by the client before development of the product.
Definition of Lease Payment
Lease payment is the sum paid by the user of the asset (lessee) to the owner of the asset (lessor) for the right to use the asset over a period of time and as per the lease agreement. Lease payment is also called lease rental and is paid for a fixed period of time which is called a lease term.
Start Your Free Investment Banking Course
Download Corporate Valuation, Investment Banking, Accounting, CFA Calculator & othersExplanation
There are so many factors that influence the calculation of lease payment like asset value, depreciation, discount rates, lessee’s credit score, and finance cost. Lease payments are generally done on monthly basis. It is like rent paid to use an asset. A leased asset can be a car, property, computer equipment, software, or any fixed asset.How to Calculate Lease Payment?
To calculate the lease payment, we need three components, Depreciation, Finance cost, and tax.Step 1
(net Capitalized Cost – Residual Value) / Lease Term
Net Capitalized cost: The selling price of the asset including the dealer fee, taxes if any, and excluding the down payment and any outstanding loan balances.
Residual Value: The value of the asset at the end of the lease period.
Lease Term: The time period for which the lease agreement is signed.Step 2
Finance Cost: These are like the Interest charges the lessee would have to pay on the money used against the loan financing. To calculate the finance cost, we will add the residual value to the net capitalized cost and multiply it by the discount rate/Money factor. It is calculated as:
(Net Capitalized Cost + Residual Value) * Money Factor
Money factor: It is the interest rate decided in the lease agreement. It is usually given per annum, we have to divide by 24 to get the monthly rate.Step 3
Tax: It is the sales tax charged by the local or state government. It is charged on selling price and is calculated as:
(Depreciation Cost + Interest Cost) * Sales Tax Rate
Formula of Lease Payment
The formula of the lease payment is derived by adding the three components discussed above.
Lease Payment = Depreciation Cost + Finance Cost + Sales TaxExample of Lease Payment
Lessee Ltd took a machine on lease from Lessor Ltd for a lease term of 60 months. The selling price of the machine is $60,000 with the residual value after 60 months $2,000. The rate of interest applicable is 5%. Lessor ltd also had an outstanding loan on the machine for $5,000. The applicable sales tax rate is 2%. Calculate monthly lease payment.
Here is the calculation of monthly lease payment:
Machine Value 60,000
Residual Value 2,000
O/s Loan 5,000
Interest Rate 5%
Sales Tax Rate 2%
Lease Term 24 (months)
Depreciation Cost is calculated using the formula given below:
First, we have to calculate the net capitalized cost,
Net Capitalized Cost is calculated as
Net Capitalized Cost = Machine Value – O/s Loan
Net Capitalized Cost = 60,000 – 5,000
Net Capitalized Cost = 55,000
Now , Depreciation Cost is calculated as using the formula given below:
Depreciation Cost = (Net Capitalized Cost – Residual Value) / Lease Term
Depreciation Cost = (55,000 – 2,000) / 24
Depreciation Cost = 2,208
Finance Cost is calculated using the formula given below:
(Net Capitalized Cost + Residual Value) * Money Factor
First, we have to calculate Money Factor,
Money Factor = Interest Rate / Lease Term
Money Factor = 5% /24
Money Factor = 0.002083333
Finance Cost is calculated as using the formula given below:
Finance Cost = (55,000 + 2,000) * 0.002083333
Finance Cost = 119
Sales Tax is calculated as
Sales Tax = (Depreciation cost + Finance Cost ) * Tax rate
Sales Tax = (2,208 + 119) * 2%
Sales Tax = 47
Monthly Lease payment is calculated as
Monthly Lease payment = Depreciation Cost +Finance Cost + Sales Tax
Monthly Lease payment = 2,208 + 119 + 47
Monthly Lease payment = $2,374Lease Payment in Income Statement
There are two types of lease, Operating Lease and Finance lease. The accounting treatment and recording of lease payment in the Income statement depend upon the type of lease.
Operating Lease: A lease is classified as an operating lease if it does not transfer substantially all the risks and rewards incidental to ownership. Lease payment is recognized as an expense in the Income Statement of Lessee in case of operating lease
Finance Lease: A lease that transfers substantially all risks and rewards incidental to its ownership is called a Finance lease.
The asset is transferred in the books of the lessee at a fair value or present value of minimum lease payments, whichever is less.
Depreciation is charged by the lessee in its Income statement over the lease term or useful life, whichever is less.
Lease Rentals constitute principle repayment and Interest, Interest is charged in the Income Statement.Importance of Lease Payment
It is important to understand the lease payments in order to correctly record them in the books of the lessor and lessee.
Lease payment is one of the major factors to decide the type of lease, operating lease, or finance lease. For example:
A lease is a finance lease where the Present value of Lease Rentals is equal or approximate to the fair value of the asset.Benefits
Below are some of the benefits of Lease payments:
Lease payments are mostly done on monthly basis. So, there is no major outflow to cash at one time like in the case of purchasing the machinery. So, it helps to maintain the liquidity of the company.
The money saved from leasing the asset instead of buying can be utilized in other areas which need investment.
The risk of an asset becoming obsolete due to a change in technology lies with the owner of the asset.
Lease payments are shown as expenses in the books of the lessee which reduces its income and further reduces the tax liability.
In case, the value of the leased asset gets appreciated, the user of the asset has no right to such appreciated value.
In the case of an operating lease, the asset is not shown in the balance sheet of the company and is considered as a long-term debt, which affects its valuation.
Lease payment being an expense reduces the net income of the company which in turn shrinks the income available for the equity shareholders.Conclusion Recommended Articles
In this tutorial, we’ll learn how to set up an in Power Automate. There are times when flows can’t be fully automated and might require some user intervention.
Approvals are very useful because we can automate some part of the flow, and split the part that needs user intervention into its own separate flow.
For example, there could be a flow for an expense request. It will be processed through regular channels. However, someone still needs to look at it just to make sure that the amount makes sense. If it’s over a thousand dollars, the request should undergo approval before the flow continues.
Then there’s a condition where if the item includes an issue or problem, it creates a Trello card. Otherwise, it retweets the tweet.
However, we might not want to retweet it until an actual human being approves it. Hence, we’ll put an approval right before it gets to the retweet step. The automated flow will actually pause when it gets to that point, and will continue once the user approves it.
Let’s now create an approval workflow. First, we need to add an action.
There are three different actions for this connector. You can either create an approval, wait for an approval, or combine those two things together (Start and wait for an approval). We’ll choose the second option because we want to both start and wait for an approval to go through.
There are four available approval options for this action. Let’s choose the First to respond option.
I’m going to copy and paste the email address that I used for this organization. Make sure you use valid emails.
We can also assign multiple people. We can have 20 reviewers and only one of them needs to actually approve them.
Let’s also add space.
After that, type in “Name: ”. Again, make sure to add a comma right after that.
We want the retweet to actually happen after the approval. So, we need to switch the order of the two actions. Move the Retweet action below the “Start and wait for an approval” action.
The condition is if the outcome is equal to “Approve”.
If the condition is true, then it should be retweeted. Therefore, let’s move the Retweet action inside the “If yes” path.
If it’s not approved, we want a record for that. So, let’s add an action within the “If no” path.
Then choose “Create a card”.
Choose Tasks for the Board Id field and Issues for the Parent List Id.
For the Card name field, type “Tweet has been rejected”.
As for the Description field, choose “Tweet text” within the Dynamic content tab.
Let’s open Twitter and tweet “Power Automate is AMAZEBALLS!”.
Again, this usually takes a few moments because it’s constantly querying Twitter. After the flow runs successfully, go to Approvals.
We’ll then see that there’s a new approval request.
Let’s now analyze how our flow worked. The process has gone through the condition.
The tweet doesn’t have the word “Issue”. That’s why a Trello card wasn’t created yet. Instead, it waited for an approval.
As we can see, it contains all the arguments that we required such as the tweet text and the name of the person who tweeted it.
Because of that, let’s approve the tweet.
Let’s now go back to our flow. As we can see, the condition was true. Therefore, the action (Retweet) within the “If yes” path was executed.
Once we check our Twitter, we’ll see that the tweet was already retweeted.
And that’s how you can manage approvals in Power Automate mobile app.
We’ve successfully created an approval workflow in Power Automate. Keep in mind that flows don’t need to be fully automated, and you don’t have to worry about being uncertain of what might happen in your flows. You can just include user intervention into your flows and make them more customized and logical.
If you’re a consultant and you’re going to deploy Power Automate into a company, a lot of these approval processes and tools are built-in for you. This makes the user experience in Power Automate so much better, especially when users can do everything from both their desktop and phone.
All the best,
What is VUGen?
VUGen (Virtual User Generator) is a key tool in LoadRunner to create testing scripts to emulate real-user behavior on your system. In VUGen, a human is replaced by a virtual user (VUser) and the actions performed by a VUser are recorded in VUser script to emulate the real-user behavior for testing and monitoring.
VUGen is one of the four core components of LoadRunner. It is the first component you interact with when getting started with Performance Testing using HP LoadRunner.
Let’s understand a few salient features related to VUGen
VUScripts: As already described, the purpose of VUGen is to create VUScripts that are used to simulate a real-like virtual-user.
Actions: An action is set of user transactions performed in the System Under Load to achieve a defined task. An action can be compared to a function in other programming languages. Each Vuser script has 3 default functions
Vuser_init(used to login into the application)
Action (used to record the business process)
Vuser_end (used to logout of the application)
VUGen not only records scripts but also replays them (for only 1 VUser) to ensure script is recorded correctly. Once you ensure the script is recorded correctly you incorporate it in a LoadRunner scenario
In this tutorial, you are going to study
The script development process in VUGen
1. Record the Script: Usually, this is the first step of scripting where every user action is recorded into a script.
2. Replay and Verify: Once the script is recorded, reply the script to ensure its working right. Verify any impact through application frontend or database.
3. Enhance the Script: Once recording has been verified, enhance script by adding checkpoints, validating data, adding transactions and rendezvous points.
4. Replay and Verify: As earlier, re-play your script and verify that everything is working as intended.
5. Configure Runtime Settings: Configure and control pacing duration, think time variation, proxy settings and whether you wish to ignore any external resources.
6. Use for Load Scenarios: Formulate load scenarios based on test objectives. Use load distribution and geo-wide agents to make real like scenarios.Compare recording between QTP and LoadRunner
VUGen disregards UI Objects:
Unlike QTP scripts, LoadRunner scripts are independent of GUI. This is because the code generated does not work based on UI objects, rather, it works on the principal of client’s request to the server and expecting server response back to the client. This is why replaying LoadRunner scripting is always browser independent. The VUser can communicate directly with a server by executing calls to the server API-without relying on client software (SUL) this means there will no impact on scripts if the changes are made to the UI of the System Under Load. This tells; the Performance Testing is completely based on client/server communication (request and response) and not the GUI objects.
We will see in more details how VUGen scripting works below.Introduction to Web Tours Application
For all hands-on purpose, we will be using the Web Tours Application that comes bundled with LoadRunner.
Once the “server” has been activated, it will open a shell and output on the console.
The console should look like snapshot below, look for your IP address in the shell:
NOTE: if you close this window, the server will stop.
Now you can access the Web Tours Application –
Once launched, it will look like –Understanding the VUGen Environment
VUGen splash screen will appear as follows
The splash screen will subsequently open HP Virtual User Generator Home page, as shown below:
From the File menu, you can observe various command controls. The purpose of these controls are mentioned below:
New Script and Solution: is used to start creating a new script. Alternatively, you can create a new script from the toolbar button.
We will get acquainted with other controls as we start creating our first script. Let’s continue learning.
Creating Your First VUGen Script
Before you record, make sure the Web Tours App server is running. Remember, you need to keep the server running so do not close it. If the window bothers you, you can minimize it.
Tip: In a real-world problem, one needs to get acquainted with the subject application (SUL) especially if it involves complex business workflows and data stages. You can also interact with HP Web Tours to ensure you can repeat the exact steps when recording.
Before one can start with scripting of any application (SUL), one needs to get acquainted with the application flow. With this tutorial, let’s get acquainted with HP Web Tours which is shipped and automatically installed with HP LoadRunner.
You can use the shortcut (Ctrl + N) to do the same.
Step 2) A window to select the protocol is shown. The list looks slightly different from previous versions
1. Select Single Protocol
3. Enter Script Name
Note: You can use Protocol Advisor to determine right protocol your application uses for communication. For HP Web Tours, we already know that it requires “Web – HTTP/HTML” protocol. We will learn at a later stage how to determine the right protocol for your SUL.
Tip: An application may require more than 1 Protocols sometimes to communicate with its server. For such a case, navigate to Multiple Protocols list on the left side of window.
HP Web Tours, however, requires only one protocol when scripting with VUGen.
Tip: You cannot rename your scripts easily, so be creative when giving your scripts a name. If you’ve to rename a script, use Save As feature and give a new name. A good nomenclature could be something like WT01_Signup where WT is a short form of the application name, 01 is a business process sequence, and Sign up refers to the business processes being scripted. Also, note that you cannot use spaces in a script name.
Step 5) a new window opens
1. If we study the above window, the name of the script is mentioned in the title bar of this popup. This will help you make changes to the right script when you are dealing with multiple scripts opened at a time.
3. Record into the action field determines where the code is generated after recording. VUGen scripts facilitate switching to other actions or creates new actions during and after recording.
4. Record: field tells VUGen that the subject application (SUL) is a web application or a desktop client. This option cannot be overridden once recording begins.
5. Application: field tells VUGen, which browser to use for recording. If you are not working with Web – HTTP/HTML protocol, you will select the desktop client with this field.
Tip: Unlike QTP scripts, LoadRunner sample scripts are independent of GUI. This is because the code generated does not work based on UI objects, rather, it works on the principle of client’s request to the server and expecting server response back to the client – usually, in the form of HTML (hence the name of a protocol)
8. Working Directory: This is a temporary directory which VUGen will use while capturing events. A copy of your script will be available at this location as well, just in case if you lose your folder 🙂
9.Recording Options: These settings tell VUGen what type of URLs to capture and what recording mode to use.
Step 6) Once recording starts, VUGen will invoke the HP Web Tours application using the browser selected.
Let’s understand with a LoadRunner scripting example to Sign up a user at Web Tours application and record a basic script.
A floating recording bar will appear which will offer various controls over recording. This tells the time elapsed and a number of events automatically captured. Let’s look at the floating bar closely.
In the snapshot shown above, the SUL has fired 56 events and a total of 0 minutes and 25 seconds of time duration has elapsed since recording began.
You’ll also observe that no events are fired as you type. Ask yourself why. Can you answer?
Recording can be pause
using the pause button. Please note, as long as the recording remains paused, all events being fired by the application will be disregarded. This also means that even if your application is sending requests and/or receiving response form SUL, the script will not be generated as long as you’ve paused the recording.
button from the floating bar to resume recording.
While you are recording in vuser_init section, you’d notice that rendezvous button is not enabled. Switch to Action (or create a new Action) and continue recording. Refer to below snapshot to learn how to switch Action.
You’ll notice that after switching to an Action, the rendezvous
button will be enabled automatically. This is because VUGen does not allow insertion of rendezvous points in vuser_init.Using Transactions at Record Time
button will be enabled automatically. This is because
Let’s assume you wish to gauge response time when X number of users simultaneously Sign up. To address this objective, let’s read further.
By now you’ve recorded opening of the application in vuser_init action. After you’ve switched to Action, enter the user information required by SUL. Now before you hit “Continue” button, follow below steps:
in floating bar. Enter the name of the transaction, for example, 01_Signup.
Tip: It is a good practice to name your transaction with a prefix like 01_ to help keep them unique.
The floating bar will look like this:
If you do not have multiple transactions opened, you’ll see only one name. If you’ve multiple, however, you’ll 0be able to select from the list.Insert Comments at Record Time: Code Generation:
Immediately after VUGen finished “Performing post generation operations” it will start “Performing scan for correlation post generation operation” We will see in more detail what correlation means.
Once post generation operation is finished, you will see Design Studio window. If any candidates for correlation are found, you’ll be able to review them in this window.
The window will look like this:
As highlighted in the above figure, the editor contains easy to understand, readable code. You can have a look on the parameters used while recording.
The left side of VUGen is called Step Navigator that lets you understand the “script” without looking at the granularities of the code. For example, you can read steps as, opening a URL, spend Think Time and submit the form. This encapsulates all the parameters associated with each request.
Now, congratulate yourself for having your first script successfully generated and saved.Deciding a Protocol and Protocol Advisor
You might have questioned yourself why did we use Web – HTTP/HTML protocol. How did we decide which protocol should we use? The answer is not that simple.
There is an architectural foundation set of skills you need to have in place as a prerequisite to answering this question. If you are a beginner, you can pair up with someone who has solid client-side architectural and development skills for your SUL. You can speak with the developers of your SUL and find out which interfaces your application leverages. This should lead you on a natural path to the interfaces that you will be using for your virtual user script development and protocol selection.
Refer to snapshot below:
This will open the main window of Protocol Advisor. If you notice, this resembles a bit with the window appearing for recording. Let’s have a look at the window below:
Select the Web Browser since we are using a web-based application.
Specify the URL of the application that will subsequently be invoked. Working directory can be left as such since this is merely a temporary directory for VUGen to use. Ensure you’ve read and write access on this directory.
A floating bar, somewhat similar to the record time floating bar will appear. Have a look at the snapshot:
The process will tell the time elapsed and a number of events fired. However, this information is not necessary. The only benefit of this events counter is, you know your client, SUL, is communicating with the server.
It is a good practice to analyze only one business process at a time since the various business process in a large enterprise application may involve various protocols. For example, a dashboard in some application may have Ajax or Flex, etc. but this will not be present on the login page.
You can see the suggestions from Protocol Advisor. These may or may not be the best choices to pick.
You’ve learned to use Protocol Advisor by now. However, this could be helpful for beginners or for a situation where you need “another opinion” – rely on your architectural sense, programming knowledge, development skills and information received from the development team to decide on the protocol.Recording Options
Whenever VUGen generates a script, the code generated is based on various configurations that can be found under the “Recording Options” – or you can press Ctrl + F7 to view the Recording Options in LoadRunner.
Let’s have a look at recording options window before we discuss all configurations:
There are various categories of configurations like General, Correlations, Network and Data Format Extension. Let’s understand most significant among these, one by one.
This topic requires detail understanding. Hence this is discussed separately.
Have a look at the snapshot for a glimpse:
You’ll notice that Language dropdown is disabled. A common myth is that the LoadRunner does not generate code in any other language. Another myth is that it requires a license to work in other languages.
Both are false. LoadRunner decides for itself which language to use when generating the script. In almost all cases, you’ll find yourself working with C Language.
VUGen will generate a script in VBScript Language only for applications developed in Visual Basic classic (MS Visual Studio 2002)
You can opt to “Generate fixed think time after end transaction”. This means, no matter how much a user wait, the think time generated (the delay) will be equal to value specified. The value is in seconds.
A maximum number of lines in the action file refers to the maximum number of lines VUGen will generate an action. If the script is larger, VUGen will automatically create a new action. The default is set to 60,000. The maximum value which can be specified is 65,000
You may find this configuration helpful when dealing with a desktop application with Oracle on the backend.
Essentially, this will be used only when you wish to Re-Generate Script.
Have a look at the screen:
This is helpful when you’ve used multi-protocols at the time of recording a script. You can regenerate the script and deselect the protocols you don’t wish and get a new script without having to re-record it.
Have a look at the snapshot below:
This configuration tells VUGen to find candidates for correlation at record time. If you do not wish for Automatic Correlation, then you might wish to turn off this feature.
Have a look at the screenshot below and familiarize yourself with the screen.
This frame offers various settings related to HTTP binding.
Reset context for each action, enabling this option instructs VUGen to reset all HTP contexts between actions to their initial state before recording, providing a clean beginning for the recording session. The option is enabled by default.
You can leave the rest of configurations intact unless required.
This frame should be left intact. If you’re recording a desktop application, then you may have to choose WinINet level data.
You can go to Options (as long as you’re using Socket level data) and select various options like SSL version or other types of Secure Socket Layer. If you’re a beginner level or do not require these options, you can skip. Have a look to get yourself acquainted with the screen.
Now you’re done with most of the Record Time options, let’s move to the next topic and understand the difference between HTML and URL based scripting.Difference between HTML-based and URL-based Scripting
You may have noticed an option to pick either HTML-based script or URL-based script. Have a look at the snapshot for a flashback.
So what is this option and which one to pick?
The HTML-based script is based on user actions, and the scripts contain functions that correspond directly to the action taken. Let’s understand example of a small piece of code:
Example:web_link(“Enterprise Systems Performance", "Text=Enterprise Systems Performance," "Snapshot=t4.inf", LAST);
The URL-based script is based on HTTP requests sent to the server as a result of user actions.
Here is an example of code for URL mode for the same actions performed as above (in HTML mode)
Example:web_url(“Enterprise Systems Performance", "URL=/esp.html", "TargetFrame=", "Resource=0", "RecContentType=text/html", "Referer=/atc?. . . , "Snapshot=t4.inf", "Mode=URL", LAST);
Tip: It’s best to experiment yourself before you move forward. Change the record time settings and record the same script twice i.e. once with HTML mode and once with URL mode – then compare both. Keep the script short so you can understand the difference.
How do we decide on which mode to use?
Let’s understand the pros and cons of both modes so understand which mode is more suitable under certain situations:
Benefits of HTML Recording
Reduces need to capture dynamic values
Action tag values and hidden data are NOT hardcoded
They are retrieved from memory during playback
If they are dynamic, the VUser still run
Script is only as big as the business process–one step per page
Scripts are less scalable
Memory (cache) is searched during playback
requires more memory
requires more CPU power
Benefits of URL Recording
Support for Java Applets and ActiveX objects on the page
Ability to replay on UNIX
Scripts are more scalable than HTML scripts because they require fewer resources
Scripts require more correlation (nothing is retrieved from the cache)
Context-sensitive checks won’t work (parser is disabled)*
Scripts are large (all images and frames are recorded as separate steps)
Here is a quick illustration:
HTML Mode URL Mode
Intuitive and easy to understand. Not as intuitive as the HTML scripts.
Scripts are smaller, requests are encapsulated and easy to understand. Scripts are large, containing a call to each image, css, html, etc. thus making it difficult to understand.
Scalable. More scalable and effective for creating a load test.Use of Re-Generate Script
Let’s suppose you want to record the same script you just recorded, but with different record time settings. In such a case, you can use the regenerate script feature.Playback a Script and understanding Log
in the toolbar to replay or hit F5.
You can find this button in the toolbar:
You need to ensure the server is running (which is required for application to work properly)
When you replay the script, you’ll notice that unlike QuickTest Professional, it doesn’t open any browser to replay. Remember, this execution will simulate only 1 (single) user load on the SUL. The purpose of this execution is to ensure your script is working.
Tip: You’ll need to verify the impact from the application itself. For example, if you’re creating a record, go to the application and verify manually that your script actually created a record. Your scripts, most likely, will not be tested by yet another Testing or QA team so you need to be very careful with your script and ensure these are thoroughly tested.
You can leave the replay log active since this will be a great help in identifying candidates for correlation and any errors and warning you might come across. Since generating log takes ample resources, it is best-turned off when you’re done with debugging of scripts and using them for scenarios.Overview of Files Generated During Record & Playback
Let’s close the VUGen and have a look at the files it has created in the script folder.
VUGen creates a series of configuration files, data files and source code files which contain VUser run-time and setup information. The results of each iteration of the script are stored separately. If you’ve executed your script at least once, you will notice a directory by the name result1. This directory is for system use and should be ignored by the tester.
Important files which you need to understand:
VUGen will create one .c (C Language Code file) for each action. Thus, at the last, you’ll have vuser_init.c and vuser_end.c and Action.c – if you’ve more actions created, you will see corresponding files too. For example, myAction.c
The replay log is saved in a file called chúng tôi If you’ve replaced it multiple times, chúng tôi will contain the last execution log whereas, chúng tôi will contain previous to the last run.
You will see a folder named “data”. This folder keeps an image of the events as well as a copy of your code. VUGen makes use of these files when you “ReGenerate” your code.
Update the detailed information about Cyclomatic Complexity In Software Testing (Example) on the Moimoishop.com website. We hope the article's content will meet your needs, and we will regularly update the information to provide you with the fastest and most accurate information. Have a great day!