Tuesday, March 8, 2022

Solving: Question on Automating a Finance Web Application

 

Requirement for Web App Test Automation Framework


I read this question on The Test Tribe's Discord community server.




Here is the copy-paste of the question:

Hi all,

Could I have your expertise on below.

I have a requirement to build a test automation framework for a Web Application. Web application is developed using java and MySQL.

And the domain is related with finance sector. 

Most of the functions in the application is working with scheduling services which the service will triggered automatically. Mainly they wanted to verify the data which are displayed in UI with the database. Which means the data which is created with the scheduling services are added correctly. 

Some of the testing scenarios are as below:

1. For each transaction it will create a ticket and need verify the data which is on the ticket.

2. There are some configurations ( like rules) which will used to create behaviors of the transactions and have to verify the transactions will work according to the rule.

3. Whether the ticket is created for the correct user.

4. There are notification rules as SMS, Email and Letters, and needed to verify whether the correct notification rule is triggered. 

5. Verify if the ticket is automatically closed if outstanding or arrears is fully settled.

For automate this kind of scenarios what is best testing methodology ( tools, BDD vs TDD, framework type) should I use for create the framework and writing the test scripts.

Hope you got the above.

Could you please share your thoughts on this. It will be grateful. 

Thank you.



The Common Large Question


Listen to any Test Engineer who wants to start the automation, more or the same this will be the voice and words.  I was here and at times I will land up here when I have to pick the tooling part.  How I drill through this landscape and accomplish the mission will define who am I.  

This is the strategic part of testing and automation.  If this is firm to support the context, it can bring the values.  Else, I keep adding the costs to myself, the project, and the business.  The execution of the strategy will happen with what we pick; but, did it serve what we expect?

I want to demonstrate and share strategic thinking and apply it to arrive at an approaching and execution plan.  Doing this best to the context, will leave me with minimal costs to handle and survive with.  At least, I believe it so.  Just to make sure you are with me till here, do you hear such a similar question from Test Engineers who want to automate or start the automation practice?  

To me, this is one such common large question that I come across when I listen to testers and me.  I say it large for this reason -- the number of times I hear this question is beyond the count I can keep in my practice.



Interpretation of the Need and Requirement


As I read the requirement written and the follow-up discussion on same in the TTT's Discord space, I learn:
  • The present execution state of automation
    • Looks like no automation is written for this web application
  • What's the product?
    • It is a finance application
      • The web UI is the user interface for this application
    • Is there any other user interface for this application?
      • Not sure
  • What does the product do?
    • As said in the requirement,
      • The majority of business use case and function flow is to do with scheduling service
      • This scheduling happens automatically that is the system takes care of it using the input from the user -- which can be seen as one transaction
      • There are rules which can be called configurations
        • These rules will define how and what the transaction must do
        • Need to validate if the transaction adheres to the set rule
        • Need to validate if the ticket is created to the right user using this rule
        • Need to validate if the notification rule executed is right
          • The different types of notifications available
            • SMS
            • Email
            • Letters
              • Postal letter?
        • Each transaction will create a new ticket
      • Validate if the ticket is closed by the system on outstanding credit or arrears is completely settled
  • Technology and Tech Stack
    • Java and MySQL is used in this web application
    • Could be, 
      • The backend is written in Java
      • The database uses MySQL
    • But the system as this that involves scheduling and notification will have queuing, caching, messaging, and searching operations
      • The tech stack used for this is not mentioned in the requirement
      • Imagine a system that has to initiate the postal letter notification
        • This is something which involves not just software but also the people interaction very much
  • Help Expected from Community
    • As written in  the question posted
      • "For automate this kind of scenarios what is best testing methodology ( tools, BDD vs TDD, framework type) should I use for create the framework and writing the test scripts."



Microservices and Where to Automate


I guess this product should have been built using Microservices.  When I say Microservices, I mean, a small, modular, replaceable, independently developed, and independently deployed software application that is responsible for performing one function within a large system.

The diagram of microservice system

An illustrative representation of Microservices system


When I have to pick the automation in the large system built using Microservices, I will know what is that I want to accomplish from automation?  And, this is one of the primary questions to be answered irrespective of what the system is and how it is built.

Further, this leads me to know and understand:

  1. What data do I need to test and validate?
  2. Where to validate data?
  3. How to validate data?
  4. Which is faster and more efficient when validating the data?
  5. What is the expectation when validating the data?
This does not rule out or hold up any layer of the system.  In fact, this helps to know the importance, priority, and criticality of the layer (seam) where I have to start or have my tests concentrated.

I have missed showing the "data" within the hosting area in the above picture.  With that, I ask where should I test and automate to look for what I want to learn.  When I have this picture of my system in mind and how the microservices interact with the tech instances, it directs me to talk with appropriate team members and get started.


Getting Started to Automate in this System

Reading the problem statement and what is expected, it is nowhere mentioned by the tester -- how to automate on the web UI or API or other tech instances of the product.  But, the tester has mentioned the flows and their outcome which should be covered in the automation.

If I had to start testing and automation, I will do the below and assess:

  • APIs:
    1. I look at how good and deterministic is the APIs in processing the requests
    2. Can I take the response of API to infer the system looks to function as expected
    3. If yes, just this has to be taken by the client interface and display the result?
    4. Can I test the notifications at this layer with help of automation?
    5. Can I test the rules at this layer with help of automation?
    6. Can I test for the configuration here?
    7. Can I test for the ticket creation and its state updates?
  • Web UI:
    1. Do the contract between the web UI and API is obliged or does it have any problem?
    2. Is there any JS feature on web UI that takes and processes data further?
      • If yes, do I need to validate this to understand the correctness degree of the data to decide?
    3. Or, the web UI just accepts the response and display the data?
  • Databases, Queuing, Messaging, and Caching:
    1. Is there a need that I should be testing and automating at this layer to decide on the data displayed?
    2. Should I test here in association with other tech instances or in isolation to know the data?
    3. Is testing of Microservice and its endpoint is sufficient?  Or, should I also include these tech instances in testing together with Microservice?

This will set me on the path now to decide where to start automation so that it assists and speed up my testing.  If the Web UI consumes the data from the endpoint and display, I will begin automation at the API layer.  This is simpler, faster, and can help me to figure out the problems distinctly at web UI and API layer.  

If I started automation at the web UI layer to determine the correctness degree of data, maybe I will have to spend more time to automate in this context.  If I have the freedom to go ahead, I will update the team and stakeholders on why I'm going ahead with this decision.  Or, if I have to present it to stakeholders and then start, I will present the work with data i.e. time, what is covered, and how much along with what is not covered and why.

That said, I'm not saying -- I do not automate at the web UI layer.  I'm saying, where will I start and why.  Making sure one part of the system is deterministic will help to figure out the problems in the other parts of the system.  The question from a fellow test engineer says, a requirement of automation for web application and not automating the application on web layer.

The tools and methodology come with culture and practice followed in the project.  At least the test engineer will have choices on the tools and library side though not at methodology.



Saturday, March 5, 2022

The Never Ending Execution and Code Smell

 

I write this post to share my learning with all Test Engineers and not just be confined to Testers in a group.  I read the below question in the Telegram group - Testing Mini Bytes.  

A fellow Test Engineer in the group asked this question by sharing the method where he experienced a problem.

Question:

This is going on infinite loop can someone let me know why the loop the condition is not working



Pic: The method whose execution is not ending


Here is how I approached analyzing the stated problem and asisted the fellow engineer:

  1. Read and understand the problem description
  2. Understand whose problem it is and why from the description if the detail is available
  3. Know the Programming Language used
  4. Read the code and understand its flow
  5. Looked for the debug statements
  6. What is declared and how, why, and what does it hold?
  7. Check if any state exists and what it is
  8. Logic check for condition and flow
  9. Check on maxAttempt count
  10. Syntax check for condition and flow

Now, I look at how the condition check is being done:
  1. The operator used in condition with the operands
  2. Declaration
  3. Assignment
  4. Updating
  5. Referring

In this case, the condition has IF and ELSE blocks.  The IF block has a check on the status and maxAttempt count.  The IF condition has logical AND between these two.  And, the ELSE block has a check on maxAttempt count alone.

What I infer is:
  1. The operator != should not be a problem in this case
  2. Though JS also has !== operator, != should work in this context; !== also works if used
  3. Could be the status is not yet COMPETED or COMPLETED
  4. But, the maxAttempt will not be less than 5 in the first check
  5. maxAttempt is incremented
  6. And, the same having this IF and ELSE block is called
    1. Doing so, the maxAttempt will be reset to zero
    2. Note that maxAttempt was incremented before resetting it to zero
    3. In this method, maxAttempt will always be zero that is less than 5
  7. Irrespective of whether the status is COMPLETED or not, this execution will run into a loop


Not having the debug prints or console log for status and maxAttempt, it won't be obvious why this execution is going on & not stopping.  It is a kind of recursion experienced that is not intended to be here.  Unless short of system resources, this recursion continues.

Though I see the condition check logic can be written in other approaches, I did not get into how it can be done.


Learnings

  • Use the debug statements or console logs; it helps in debugging and understanding what's happening
  • Code Smells
    • Multiple Point of Failure
      • The place where the maxAttempt is declared and initialized
      • How the method is being called within it
    • Long Method
      • Though the method is simple in what it does, it involves multiple operations
      • Also, the method calls itself within it
        • It complicates by calling itself; breaking this method is good
        • One method one task
The method looks simple but how it flows within by resetting maxAttempt to zero.  And, a recursion kind of nature makes it uneasy to follow when there are no debug statements.




Monday, February 14, 2022

Model, Oracle, and Perceived Quality

 

These words are one of the most repetitive words in my blog and also in the testing community's discussion.  Nevertheless, I write a blog post on it and share my interpretation here on the understanding of it.  I came across a discussion on these words in one of the testing communities. Here is how I see it as of today with my practice of Software Test Engineering.


Model


The "Model" can be seen as a representation.  In Software Engineering, we use models as a reference to build and develop the product.  Software Testing can be leveraged when we use the models to design, build, execute and interpret the tests.  How I build the models or see models can vary each time in my work.

Today, as I write this blog post, here is how I understand a model:

  • Model is how I'm understanding
  • Model is what I'm understanding
  • Model is what I have understood
  • Model is what I have to understand
  • Model is also what I have not understood and what I am not aware
    • But, this would not be included as a part of the picture or written in the model most times
      • We tend to see the model as a working object (always?)
      • In the working object, having something not understood and not aware is not a common practice
  • A model can be a non-diagram and the organized documents or words
    • I look at The Constitution of India as a model on which I live in the Indian society

Usually, one looks for a diagram on hearing the word "mode".  I did this, that is I looked for the diagram and continue to do so.  But the model need not be a diagram always.  But, the diagram helps better in relating and understanding.

Example of models:
  • A representation understanding of me how I can broadcast YouTube live stream on Zoom
    • Here I can have multiple models
      • From a tech layer spanning to a UI layer of Zoom and then to people who are watching it on Zoom, YouTube or both
      • And, many more models like this
    • If I'm on a sales team, my model thinking on the same would be different
      • Like which platform that is YouTube or Zoom caters the content to the maximum audience I'm focusing on



Oracle


In a context-free case, I will say Oracle as -- It is a reference which I refer to learn and interpret what I'm experiencing or about to experience.  It helps me to understand and in decision making.

That said, the Oracle is not a source of truth.  It is a reference and so it is a heuristic.  If it is a source of truth, can it be a heuristic?  This is the challenge and confusion one goes through in understanding and drawing the relationship between the oracle and heuristic.  When we understand oracle and heuristic, it is simple to draw the relationship between them and know when it can serve as the other.

When heuristic is taken as a source of truth, it can fail to be a source of truth at any time.  Heuristic is a fallible way of solving a problem or making a decision.  That said, not all heuristics are oracles; and, the oracles can be used as heuristics.

In software testing context, Oracle is quoted as -- An oracle is a way to identify the problem that we experience during the testing.  It helps to identify the problem.  Maybe we use the word "problem" as we are into the context of Testing.  Testing is expected to figure out for what it is commissioned; in most cases, we take it is to find the problems.  So that definition or quote for the word Oracle in software testing context has the word "problem" with it.


Example:
The 1000 INR currency note that we had in India, was a valid and acceptable currency.  If someone asked before demonization this was accepted as truth.  But today, it is not a valid currency and this is accepted as a truth.


The 1000 INR currency note was a valid currency until 8th Nov 2016.  This currency was used in daily life transactions by people.  This is a heuristic and as well oracle.  

Today, a 1000 INR currency note is not a valid currency.  This is an oracle and as well a heuristic.  

If I go with 1000 INR currency it will not be accepted in transactions.  People will identify it as a problem if this currency note is exchanged in a transaction.  

  • Oracle: 1000 INR currency is not valid and accepted in transactions at the time of writing this post.  So not to tender 1000 INR currency in the transaction.
    • This gives an example of an oracle as a heuristic
  • Heuristic: Use the other available valid currency in a transaction.  Is there any Indian currency note that is invalid today?  What are the valid currency notes that I can use today?
    • This gives an example of heuristic as an oracle


Perceived Quality


  • We experience and experience is an emotion
  • Quality is an emotion and an experience
  • How I perceive the emotion and quality from testing or by any events/actions might not be the same to another person
    • But it is still valid and authentic because that is what I perceive and experience
Coming to the text "Perceived Quality", I have two questions:
  1. How do I perceive the quality as a tester?
  2. How the business and stakeholders perceive the quality by referring to feedback from testing?
Whose opinion and perception of quality matters?

Here is my thought for now on this:
  • As a Test Engineer, I try to provide information from my testing
    • The information with a compelling and influencing story of my testing
      • The outcome of my testing
      • The potential consequences of the outcome as I perceive
  • I have my words to share about my emotion and experience
  • Any measures to be taken and the authority to change the direction in this regard are with stakeholders and the business
    • What would stakeholders and the business perceive about quality from my testing story
      • The outcome from this perception is crucial in the larger interest than what I perceive as a Test Egnineer
The compelling and influcing way of telling the testing story is important.  The perception what the stakeholders and business make from this story, is what they see as quality in the first sight.

I say that word "perceived quality" talks about how the stakeholders and business is perceiving the quality.  And, how as a Test Engineer, I'm influencing it with my advocacy.


Example:

Let us take a scenario where the Product Owner and Sales team are looking forward to data for making the decision. 

The product owner has a good feel about how the notification works. The notifictions are received by the intended interfaces at the time of testing. 

But, did it record in analytics about how many taps were made on notification?  No, it did not record.  The Product Owner together with the sales team needs this data to plan the business decisions.

The lack of this data will the lower quality experience of notification for the Product Owner and Sales team?  

What is the quality emotion and experience perceived here by two different teams and people?




Wednesday, January 26, 2022

Automation Strategy - How to Automate on Web UI Table for the Data Displayed in Table

 

Use Case to Automate and a Problem Statement


I read the below question in The Test Tribe's Discord community server.  As I read, I realized, we all go through it when we think of automating a use case.  The credit of this question is to Avishek Behera.


Picture: Description of a use case to automate and a problem statement

Here is the copy-paste of the use case and problem statement posted by Avishek Behera:

Hello everyone, here is a use case I came across while having a discussion on automating it.

A webpage has a table containing different columns,let's say employees table with I'd, name, salary , date, etc

It also has pagination in UI, we can have 20 rows in one screen or navigate to next 20 records based on how many total records present,it could go about 10 + pages and so on....


Problem statement:

How to validate the data displayed in table are correctly displayed as per column header , also correct values like names, amount etc. Use case is to validate data.

The data comes from an underlying service, different endpoints basically.

Now it's not about automation but about right and faster approach to test this data.

What are different ways can we think of?

I know this is a basic scenario but since I was thinking of different possible solutions.

One way my friend suggested to use selenium, loop through tables ,get values ,assert with expected. Then it is time consuming, is it right approach just to validate data using selenium?


 These are the useful attributes of this question:

  1. It had the preset of context and the context information to the reader
  2. The availability of context information gave an idea of
    • What would API look like
    • The request and type
    • The response and details
    • The consumer of this API
  3. It helped to imagine and visualize how the data would be interpreted by consumers to render
  4. I get to see what Avishek is looking for in the said context


Interpreting the Use Case and Problem Statement


What it is?
  • Looks like the consumer is a web UI interface
    • Mention of Selenium library supports this interpretation
  • The response has a data which is displayed in the table kind of web UI
  • There can be no data to multiple rows of data displayed in the table
  • Pagination is available for this result in the UI
    • Is pagination available in the API request and response or not, this is not sure from the problem description
    • 20 rows are shown on one page of a table
    • The number of pages in the table can be more than one
    • The response will have a filter flag
      • I assume that data displayed in the table can be validated accordingly
    • The response will have the data on the number of result pages
      • This makes the result in a page to be of fixed length
      • That is 20 results on each page and I cannot choose the number on the UI
      • The response will have the offset or a value that tells the number of records displayed or/and returned in the response
  • Is it a GET or POST request?
    • This is not said in the problem description
    • But from the way the problem is described, it looks like a GET request
    • But should I assume that it is an HTTP request?
      • I assume it for now!
  • I assume the data is received in JSON format by the consumer
  • I assume the data responded by the endpoint or the service, are sorted and returned
    • The consumer need not process the response, sort, filter, and display
    • If the consumer has to process the response, then filter, sort and display, 
      • it would be a heavy operation on the client and the client-side automation for this use case

If it is other than an HTTP request, it should not matter much.  The underlying working and representation may remain something similar to HTTP requests and responses unless the data is transferred in binary format.



Automation Strategy for the Use Case


The key question I ask myself here is:
What is the expectation from automating this use case?

How I automate and where I automate is important but it comes later on answering the key question. The key is in knowing:
  • What is the expectation by automating this use case? 
  • What am I going to do from the outcome of this automation? 
  • What if the outcome of the automation gives me False Positive information and feedback?

These questions help me to see:
  • How should I weigh and prioritize the automation of this use case?
  • How should I approach automating this use case to be close to precise and accurate with deterministic attributes?
  • What and whose problem am I solving from automating this use case?

It gives me the lead to the idea of different approaches for automating the same; helps in picking the best for the context

That said, the use case shared by Avishek Behera is not a problem or a challenge with the Selenium library or any other similar libraries.  Also, it is not a problem or a challenge with libraries used in the automation of web requests and responses.



Challenges in the Problem Statement


I do not see any problem in automating the use case.  But there are challenges in approaching the automation of this use case.

On the web UI, if I automate on data returned, filtered, sorted, and displayed, it is a heavy task for automation.  Eventually, this is a very good candidate for soon to be a fragile test.  

Do the below said are the expectation from automation of the use case?
  • To have a fragile test
  • To have high code maintenance for this use case
  • To do high rework in the automation when UI of the web change
  • To complicate the deterministic attribute of this use case automation
If these are not the expectations, then picking an approach that has lower cost and maintenance is a need.

The challenges here are:
  • It is an Automation Strategy and Approaching challenge
  • It is a sampling challenge
    • Yes, automation at its best is as well a sampling, not just the testing
  • It is about having better data, state, and response which helps to have accuracy in the deterministic attributes of automation
    • To know if it is a:
      • true positive
      • false positive
      • true negative
      • false negative
      • an error
      • not processable
  • The layer where we want to automate
    • The layers which we want to use together in automation, and how much
  • Automate to what extent for having information and the confidence -- if this sampling works then most data should work in this context of a system?
  • The availability of test data that helps me to evaluate faster and confidently

Let whatever the system have in the underhood that is GraphQL, gRPC, ReST API, or any other technology stack services, one has to work on -- how to make a request; go through the response, and analyze it in context.  Like testing depends on context, automation as well depends on contextIn fact, context drives testing and automation better when it is included.



My Approach to Automate this Use Case


I will not automate the functional flow of this use case entirely on the web UI.  My thought will be to have those tests which are more reliable and the result influencing and driving the decision.

This thought has nothing to do with the Test Automation Pyramid and its advocacy that is to have the minimal number of UI tests at the UI layer and much more at the integration (or service) layer.  I'm looking for what works best in the context and where to have the tests that give me information and feedback so I have the confidence to decide and act.

To start, I identify the below functional tests for the said use case:
  1. Does the endpoint exist and serve?
  2. Assuming it is HTTP,  I see what HTTP methods this endpoint serves?
  3. What does the endpoint serve when it has no data to return?
    • The different HTTP status code this endpoint is programmed to return and not programmed but still returns
  4. What inputs (data, state, and event) does this endpoint need to return the data?
  5. In what format and how the input is sent in the request?
  6. In what format the response will be returned from the endpoint?
  7. Is the response sorted and filtered by the endpoint?
  8. How does the response look when there is no data available for any key?
  9. What if certain keys and their value are not available in the response?  How does it impact the client when displaying the data in a table?
    • For example,
      • No filter data is returned or it is invalid to a consumer to process
      • No sorted data is returned or it is invalid to a consumer to process
      • No pagination data is returned or it is invalid to a consumer to process
      • The contract mismatch between provider and consumer for data returned
        • What the web UI shows in the table data
      • Any locale or environment-specific data format and its conversion when the client consumes the data that is returned by the endpoint
      • The data when sorted by consumer and provider differs
      • The data is sorted on a state by the endpoint and that might change at any time when being consumed by the consumer
      • Is it a one time response or a lazy loading
        • If it is a lazy response, does the response have the key which tells the number of pages
      • and more cases as we explore ...
  10. and more tests as we explore ...

Should we automate all of these tests?  Maybe no per business needs.  Imagine the complexity it carries when automating all these tests at the UI level.  But there are a few cases that need to be automated at the UI level.  

Then, should we to look at the table rows on different pages to test in this automation?  No!  But we can sample and thereby we try to evaluate with as much as minimal data.  This highlights the importance and usefulness of the Test Data preparation and availabilityWhile, preparing the test data is a skill, the using of minimal test data to sample is also a skill.


API Layer Test


I have a straight case here for first.  That is to evaluate:
  1. The key (table header) and its value are returned as expected
    • Is it filtered? 
    • If yes, is it filtered on key what I want?
    • Is it sorted upon filtering?
    • There is no null or no value for a key that needs to have a value in any case
    • The data count (usually the JSON array object), that is the number of rows
    • The page index and current offset value
    • The number of result pages returned by the endpoint
  2. Can I accomplish this with an API test? 
    • Yes, I can and it will be efficient for the given context
  3. I will have five to ten test data which will help me to know if the data is sorted and filtered
  4. Another test will be to receive more than 10 rows and how these data look on filtered and sorted
    • Especially in case of lazy loading
    • I will try to evaluate the filtering and sorting with minimal data
    • I will have my test data available for the same in the system

UPDATE: I missed this point so adding it as an update.  I'm exploring the Selenium 4 feature where I can use the dev toolbar and monitor the network.  If I can accomplish what I can and it is simple in the context, this will help.


UI Layer Test


I have a straight case here as well to evaluate in the given context:
  1. I assume the provider and consumer abides by the contract
    • If not then this is not an automation problem
    • It is a culture and practice problem to address and fix
  2. I assume the data returned data is sorted on the filter; the web UI just consume it to display
    • If not, I will understand why the client is doing heavy work to filter and sort
      • What makes it to be this way?
    • You see, this is not an automation problem; it is a design challenge that can become a problem to product, not jot just for automation
  3. Asserting the data in the web UI table:
    • I will keep minimal data on the UI to assert that is not more than 4 or 5 rows
    • These rows should have data that tells me the displayed order is sorted and filtered
      • Let's call the above 1 and 2 as one test
    • To evaluate pagination that is number of result pages, I will use the response of API and use the same on the web UI to assert
      • Let's call the above another test that is the second test
      • Again, the test data will be the key here
    • To see if the pagination is interactive and navigatable on UI, I make an action to navigate for page number 'n'
      • If it is lazy loading, I will have to think about how to test table refresh
        • Mostly I will not assert for data
          • In testing the endpoint, 
            • I would have validated for the results returned and its length
        • I will assert for number of rows in the table now
      • Let's call it a third test
  4. I will not do the data validations and its heavy assertions on the web UI unless I have no other way
    • This is not a good approach to pick either
    • One test will try to evaluate just one aspect and I do not club tests into one test

Note: The purpose of the test is not check if the web UI is loading the same rows in all pages.  If this is the purpose, then it will be another test and I will try to keep minimal assertion on the web UI.


The Parallel Learnings


If observed, the outcome of automation and its effectiveness is not just dependent and directly proportional to how we write automation.  It is also dependent on:
  • The design of the system (& product)
  • The environment and maintenance
  • The test data and maintenance
  • The way we sequence the tests to execute in automation
  • Where and how we automate
  • The person and team doing the automation
    • The organization's thought process and vision for testing and automation
    • The organization's expectation from testing and automation
    • How, why, and what the people, organization, and customers understand for testing and automation
  • Time and resources for testing and automation
  • The automation strategy and approach
  • More importantly, the system having and providing
    • Testability
    • Automatability
    • Observability


Note: This is not the only way to approach the automation of this use case.  I shared the one which looks much better to the context.




Monday, January 3, 2022

The Automation Strategy Problem; Not a Appium Challenge

 

In The Test Tribe's forum, I read the post which described the problem as in the below paragraphs and picture.  On looking into it, I learned this can be made as a blog post that tells a strategy for automation.  

Maybe, 10 years back I would have asked the same question.  That's a learning curve.  Today as well, I end up in thinking for a while asking self -- how to test it and how to automate it.  

I want to share how this problem can be looked at from the perspective of testing and automation, and then approach it to automate.

 

Folks. I've two issues on Appium automation which needs your help. 

1. I'm working on a ecommerce website where a payment method is integrated (lets take the example as PhonePe). When i try to place the order in the mobile website with payment method as PhonePe, the payment method app will be opened and I've to complete the payment using it and I'm navigated back to the browser. Issue is - How can i switch context between the mobile browser and the app? I tried using driver.startActivity() but on performing any other actions, it errors out. 

2. Since i need to use the browser to place order and the payment using the payment app, I tried to set up the driver instance with browserName and app as the desired capabilities together. But on running the test, it errors out - browserName and app can't be used together. How can i approach this problem? Anyone who has automated such flows?

Apologies, i'm pretty new to Appium and so, please excuse my ignorance.


Picture: Problem Statement - Description of Scenario & Challenge


Understanding the Scenario and Functional Flow

I observe the below in the said scenario:

  1. It is a website; it also has a mobile website
  2. It has got a payment option integrated
  3. The Appium's Desired Capabilities defined has browserName and the app
    • borwserName -- name of the mobile web browser used in automation; it is an empty string if automating an app
    • app -- the path of an app to be automated
  4. When using a mobile website on a mobile device -- assuming it a mobile web app
    • On selecting a payment app -- assuming it a native app
      • The context changes to payment app UI
      • On completing the payment, the context changes to the mobile website



Challenges Described in the Funtional Flow


I see these as challenges:
  • How to handle this said scenario in automation using Appium?
  • How to switch context between mobile browser and the mobile app?
  • Using driver.startActivity(), it yields an error on performing any other actions
    • On making any actions on UI after using the above said method, the error is observed
      • Reading the description, it is said that the error is thrown when running the automation
        • And, when changing the context back to mobile website from payment app
The driver.startActivity(), takes two arguments -- app's package name and activity to be started.  What's passed for the package name and activity name is not clear from the problem description.  

If the mobile browser is used to launch the mobile website and mimic the action, what is passed as app's package name and activity in driver.startActivity() ? This is not mentioned and unclear to me.

Also what is mentioned for the browserName and app in desired capabilities is not clear.



A Common Use Case


In recent years this is a common use case in a mobile native app having a web view and the websites that have payment transactions.  For example, in the native app when making payment, the web view of payment gateway that shows list of payment choices.  On successful payment, the view switches to native view from web view.



Questions on Reading the Problem Statement:


I have the below questions on reading the problem description:
  1. Why did it throw the errors on any actions post calling the driver.startActivity()
    • driver.startActivity() will start an Android activity using package name and the activity name
  2. The context picked on switching from web view to native and then back to native, is not well picked?
    • But it is a mobile website which means it is opened on a mobile browser, right?
      • No where it is mentioned as a Hybird app i.e. the mobile website installed as an app
    • Does this mobile website maintains its context when switching to a native app (payment app), and then changing the context to (web view) mobile browser?
This takes me to seek clarity for:
  1. Is mobile website a installed Hybrid app? Or, is it a regular website which also has a mobile website and accessed on a mobile browser?
  2. Is it possible to switch the context of web page from mobile web browser to native app, and vice versa?
    • I need to explore it; I'm unsure of it
    • When read the desired capabilities, it looks like this can be done
      • That is context switching of mobile web browser to native app, and back to mobile browser from native app is possible
      • I need to explore on the same to be very sure of it

Code Snippets for Context Switching


Refer to this page for details on using the Web view with Appium.  The below code snippets tell how to find the context of web and native views, and switching to it.
Snippet illustrating the change of context to Web view

Snippet illustrating the change of context to Native view



But, What's Actually the Problem?


If automated as described in problem statement, do we end up in a problem?  I see, yes we will end up in a problem:
  1. Need to maintain our automation to make sure it executes the payment app UI anytime
    • If the UI of the payment app changes, we need maintain the code
  2. Do we have stage environment payment app in this case?
    • If we test the mobile website in the stage and make transaction in production payment app,
      • Can we continue as this in each test iterations?
      • If yes, how long can we continue to use production payment app and pay?
      • Will there by any transaction fee charged each time from payment app?
        • Can this become a financial cost to the business and client or to stakeholders?
        • What other cost should I bear for using this approach?

I need to know:

  1. What is that I want to learn from the use case or scenario on automating it?
  2. What would be the impact if the test did not help me to learn what I want to learn from automating this use case and scenario?
  3. Should I be testing the payment app along with my app? 
    • As I write UI automation to handle the web view of payment gateway and then the native payment app, it becomes part of this test.  Should I do that?
  4. What information, risk and problem discovery I miss, if I do not automate the payment app flows?
    • Is it okay for the business and product, if I miss any information here or if I do not test the flow in payment app?
    • How to arrive at this decision?
The decision here need to be rational.  But, being rational alone may not help always.  Can I be reasonable here when I'm deciding or influencing stakeholders when deciding?



This is a Automation Strategy Problem!


If seen, for first this is not a Appium problem.  It is a problem with -- what to automate, how to automate, when to automate, how much to automate, and why automate.   That is, it is a problem with automation strategy on how to approach and execute it.

To me it is a problem to solve with approaching and execution of automation for payment transaction, and not a automation library usage and implementation problem.  



How can I Approach the Automation Here?


I will learn, should this payment scenario be automated on the UI layer for first?  If yes, why?  And, then I will have the below questions
  1. Can I use the developer APIs of payment service to test and complete the transaction?
    • If yes, then
      • Can I use the stage APIs of payment to simulate the transaction flow and its completion?
        • If I just use APIs, I will not know what's the functional experience of transactions in native payment app.  Is this okay?
  2. I and the product I test, do not have control over the payment system and its apps
    • When I have no control over it at any point in time, should I test it as part of my system?  If I did so, should my product as well include the probabilities and complexities of payment system?
      • Having this information is good!
      • But what can I do with that information?
        • Do I have an authority to change or fix payment system with that information?
        • If yes, good; if no, then the time and resource spent on this s a value return to my stakeholders and their business?
    • It is wise to mention that I'm not including and testing the payment system and its transactions as a part of my system
      • Because my system does not have a control over payment system in any means
  3. If the API that is used for initiating transaction is functional and usable, then I do not have to worry technically from functional perspective of transactions
    • We will have to work on -- if the payment initiating web view is functional on my native app and in my website or a mobile website
      • From here the control of payment and any transaction problem that arises are in the realm of the payment system
  4. In the test report
    • I will include the stage payment API request and its response with data
      • Talking to payment app organization, we may get the developer API access on stage to test our system on their stage
      • Talk to payment app organization!
      • Also we can mock the payment API to an extent and in the test report say this is a mock result
        • If relied on mock, then we can miss the change in payment system
        • I will have the mocking as last approach just to complete a business flow and it will not be my pick unless someone wants to see a business flow completion in a test
    • Have a test that tell about functional and usable aspect of the payment page in -- a mobile website and the payment web view in native/hybrid app


Benefits of this Approach

  1. I and my tests will have clarity what is in my control and what not
  2. When I have control, the test and automation can be well maintained
  3. The flaky areas can be identified; I can come to a decision to eliminate it from the automation or not
  4. It helps to identify what is my problem and what is the problem that I don't own in terms of authority
  5. With this approach, the tests and automation provides clarity when we uncover a risk or problem
While I know the benefits, I must also know the cost of having this approach.


Sunday, December 26, 2021

Before Identifying and Listing My Tests

 

I read the below query in TTC's Telegram chat. The discussion had started on this thread and fellow members here were responding.  Further, I read this line and it made me look into it -- "The question was we have to use valid username and password..and perform a negative testcase".



The Default Thinking and Applying Interface

Including me, I see it is subconsciously common for us to approach the problem statement visualization in terms of Graphical User Interface.  When I ask why it is so, maybe it is rooted in our subconscious thinking i.e. with first order and second order or any orders of thinking.

I want to give a try to attempt approaching it by reminding and asking self the below questions:

  1. Is it a GUI specific problem?
  2. Is it a problem that is tied to the context of GUI?
  3. What does this question encapsulate within and open as an interface?
  4. What forms do these interfaces take when I stand out of specific interface?
  5. Should I stick to one interface to learn and attempt this problem?


Identify the Tests and Framing of Tests

We test to learn

  • Does the system do what it is supposed to do and how, why, and when?
  • When the system does not do what it is supposed to do and how, why, and when?
Should I call it Negative Tests?  This is not what I share in this post.

To me, these are tests that help me to learn when the system responds and behaves in the other way than I expected.

I can start to identify the straight use cases for inputting an error (a human introduced error) at a given state/data/event; then look for the behavior of the system.  It is good when we can keep identifying and ideating the use cases.  

We get limited with use cases as we continue to think about use cases.  That said, for sure we will identify and frame the tests within identified use cases.  But, we need tests that help to learn when the system fails in doing what is supposed to do.

To supplement it there is another way, which I use.  I do not say this is the only way to supplement.  I use multiple approaches to supplement and identify the tests.  When I do so, I ask the question to the system with the help of these tests and evaluate the response of the system.


Questions to Identify the Priority Tests


I learn and understand the system each time, to identify the better tests.  And, each time I learn something new about the system that I did not know.  

When I'm asked a question in the interview, I ask for details that help me to test better or to demonstrate my deliverable better.  I will watch the questions that I ask!

If I were the candidate who got this question in an interview, I would ask the below questions.  When I learn this is good enough for the initial tests, I will pause with questions.  I move to identify and frame the tests using the responses I got for the questions that I asked.  

These questions will surely help me to be precise and close to the context that better demonstrates my testing skills.  If it is not close, then there is a problem (or a difference) in my presenting and expectations in the interview.  I will have to address it with the help of the interviewer.

Questions:

  1. What is the interface where I'm entering the username and password?
    • Where is this authentication used?
    • On UI (if so which UI), or CLI, or touch interface, or what is its interface type?
    • At which layer of the system this authentication is used?
  2. Where is the format of username and password?
  3. What is used as Authorization identity on successful authentication?
    • What happens if my authentication is not successful in the UI you want me to test?
    • How do I understand that UI is communicating to me that my authentication is not successful?
  4. How is this authentication processed?
  5. Where the authentication is mapped to authorization and stored for references?
  6. What protocol is used to communicate in authentication?
    • What protocol and communication order is used to grant and revoke authorization?
  7. Who uses this authentication and authorization?
    • To know the different means of doing the same
  8. Is there any other form of authentication that grants me the authorization?
    • Do these different entry points of authentication update my authorization?
    • Will I have different authorization data to authenticate? If yes, how the data, states, and events are maintained for my authentication and account?
  9. What's the language and Unicode supported by this system?
    • Will the languages and Unicode used in the system have any impact when I try to authorize by changing the language and Unicode?  How does the system understand these differences and maintain one state of data with authorization?
  10. Are there any computing differences for authentication and authorization on big and small endian machines?  If yes, how and for what context of the system's behavior, processing, and decision?
  11. Where and how the authentication and authorization details are processed, stored, and presented back.
    • Is there any specific reason for doing it in this particular way?
    • How you have strengthened the authentication process to grant the authorization?
      • For example, 1FA, 2FA, nFA, what else?
  12. Does any other system use your authentication to authenticate and authorize?
  13. Do you use SSO for authentication and authorization?
  14. What testability layer do I have that I can make use of to support and identify the tests?
    • Does this testability layer help me to identify more tests and also classify them?

I can keep generating the questioning like this.  But I will have to pause and start working on what the questions offer me.  

With the help of these questions, I can learn better about the system before attempting to identify the test and frame it.  This also pulls out the risk or problem area if any that looks important and of priority.

I have eased my work to an extent when I know:
  • the target surface area to start my work 
  • what it takes and brings back, and how

In this context, I would have started this way!



Friday, October 15, 2021

The Mindset to Embrace and Encourage Automation in Software Testing

 

I was brainstorming about the automation practice setup. Before getting technical, I was looking at the mindset needed. Besides this, I was with a mentee Chidambara and answering the questions.

I'm sharing the gist of pointers that we discussed and which are essential for having the encouraging mindset towards getting started and value adding automation in testing.

 

  • Build the culture that supports and encourages the Testing and Automation

  • Communicate and Collaborate

    • With testers, developers, product owners, business teams

    • Build the relationship and trust; understand the system better; seek help when needed

    • Help the team to know the value they bring from their testing and automation

  • Learn the problem; understand the problem; step up to solve the problem

    • Ask, is this a problem worth solving for the business

  • Human is a key center of the engineering

    • Human is needed for developing

    • Human is needed for testing

    • Human is needed for automation

    • Human is needed for the maintenance of all above said

    • Humans cannot be removed from action saying automation takes care of all

  • Automation is not a replacement for Testing

    • Automation exists to assist the Testing and not to replace

  • Automation involves programming and is about programming to leverage the testing

    • The libraries as Selenium, Appium, Cypress, etc., are 30% to 35% of code in automation what we write

    • The rest of the code is about how we program to build, organize, scale, and maintain the automation

    • Practice programming to write better automation

    • Embrace Programming

    • Practice Object Oriented Programming and Design Patterns

  • Automate which has to be automated

    • Automate first what has to be automated

    • Do not automate everything – yes not to automate everything!

    • What needs to be tested by humans, has to be tested by human

  • Build the skills which will help you to do the Automation in Testing

    • This is very important and not to ignore it

  • Know and confirm what is expected out of automation from business and stakeholders

    • This helps to think and define the value return from the automation

  • Know what to automate, where to automate, and how to automate

    • Automating 100% is good to hear but it is not practical and logical

    • Figure out what to automate i.e. what cases or ideas to automate

    • Identify the right layer where it is appropriate to automate

      • Automating at UI layer is a cost; automate minimal at UI layer

      • Automate at service layer i.e. API layer

      • Encourage the Unit Testing practice and culture in the engineering

  • Automate at the lowest layer which returns the maximum value and that has a low probability of failing

  • Know what should be covered from Automation in Testing

  • Understand the system being tested and its internals

    • Without understanding the use cases and business expectations out of a system, writing automation might not return the expected value

  • Have the automation strategy in place than just having/working on the proof of concept

  • Know and understand the tech stack of the product

    • Learn the architecture of the product

    • Understand the DevOps operation of the product

  • Automation is a separate project within a project that builds the product

    • The time needed for thinking, setup, configuring, coding, maintaining, and collaborating within teams are unique tasks

    • This needs its time and it cannot be adjusted with the time available for Testing

      • Note that, Testing and Automation are two different activities though automation exists to assist the testing

    • Testing and Automation are two different activities that overlap

  • Have the deterministic testability and automatability attributes in the product to leverage the value of automation and Testing

    • Ask for it with product owners and developers

  • Be informed about the value returned from the automation and its limitation

    • Keep the stakeholders informed about the same

  • Testability is the foundation in a system for Testing and Automation in Testing

    • Automatability attribute together with Testability makes the system very responsive for testing and automation

  • Do not be scared of automation; encourage the team to start thinking about it and practice it

    • Listen to all groups who are for automation and who are not for automation

    • Understand what they mean for what is being said by them

    • Learn the context in which they are talking

    • Pick what works for you, but do not ignore and be away from the practice of automation

  • Automation is a need today and for coming days; it is a skill looked for and it helps a Test Engineer very much

  • Embrace automation!





Sunday, September 5, 2021

Time and Reflection of Time - Test Engineering

 

Time and Reflection of Time


I wish to share by writing my observations and experiences with the happenings in and around Software Testing since I started my career.  Be it technical or not, I write it so I can mark the time (past and present) of Software Testing.  The time which I experienced and experiencing!  Reflection!

I will be sharing the observations and learning of me under the label Time.  My reflection is always limited; probably constrained too, as I cannot observe the happenings and development in Test Engineering at multiple dimensions in a given time.  I will try to reflect on my learnings and understanding of the changes, adaptation, and evolvement in Software Test Engineering.

Does that happening is good or bad that is not the subject of analysis.  But, the subject is to see what it is with respect to Software Testing and Test Engineering; how it contributes to problem solving in Software Engineering.

I read and understand that time is multi-dimensional.  So is the Software Testing.  An engineer can observe, look and test a system in the multi-dimension.  But is that a need?  The time in which we are testing helps to see it with a stakeholder(s) or business's decision.



Wednesday, August 18, 2021

I Can Test - Debugging an Inconsistent Behavior

 

Before I Say, I Can Test

In this post, I'm demonstrating how I approached my testing and debugged an inconsistent behavior that was reported in the Telegram space of The Test Chat.  A contest that is about to start and is hosted by The Test Chat.  The title of the contest is - So You Think You Can Test?  The registration is open.  How to register detail is shared on the Telegram chat and other social media space of TTC.

The QR Code is shared in Telegram; asked to scan and submit the registration.  Here is what I observe reading through messages in the Telegram:

  1. Few could scan the QR Code and could register
  2. A couple of members could not see the registration form as the scanning of the QR Code failed  
  3. Requests made to share the URL of the registration form than sharing the QR Code
  4. Requests made to share both -- the QR Code and URL of the registration form
  5. The reason -- why the QR Code is shared and not the URL
  6. And the URL of the registration form is also shared now

What made me curious is, a member had replied that on multiple attempts to scan the QR Code using a mobile app, it did not fetch the URL.  This member observed the same behavior on the web, that is, on uploading the QR Code image, it did not fetch the URL.

I see a behavior now to Test Investigate and debug to learn what's happening.  With that, I have an opportunity now to say I Can Test right here on the registration procedure of So You Think You Can Test? contest.


What I did and What I Observe

It is a QR Code!  

  • This QR Code shared from TTC:
    • Is not like other regular QR Code I usually see
      • I see black background and data with yellow foreground
      • I see the Finding Pattern i.e. concentric squares in an oval shape
        • These two observations are prominent in this QR Code
  • I installed a QR Code reader app on my phone and scanned the QR Code
  • It fetches me the registration form URL; I can open the registration form
  • Then I get the question -- why those testers are experiencing a problem?
  • I read through their messages and observe for clues what they have left for me
  • I read the words -- drag and drop
    • Ah! The web browser is as well used
    • This is a very useful clue to me
    • I have no idea on what desktop browser, QR Code reader websites, mobile apps, and smartphones used by these testers
  • I proceed now to use an online QR Code reader
    • I pick these two:
      • qrreader dot online
      • helloacm dot com/tools/qrcode-reader/
  • I uploaded the QR Code shared by TTC on these two websites
  • I see the same message and in the same format on these two websites
    • The message reads -- error decoding QR Code
    • Per me, this is a key observation
      • What makes these two web pages show the same message and in the same format?
  • I analyze the network when uploading the image and for the response I receive
    • In the request
      • I see the Data URL used
      • Protocol mentions data
      • No remote address, that is no server IP to which the request is to be sent
        • Another critical observation
      • I see the request initiator
      • The data (jpeg image) is sent in base64 format - a binary format
      • I can see the preview of the QR Code
      • I see the request method as GET
        • This is interesting!
        • Why GET and not POST?
      • I see the HTTP Status Code 200
      • I see just the User-Agent in the Request Headers
    • In the Response
      • In the Response tab, I see the message -- This request has no response data available
      • I see Content-Type: image/jpeg in the Response Headers

As I see no remote address for this request, I turned off the network.  I uploaded the QR Code image; I see the data URL fired.  Further, I observe this request is exactly similar to the one I see with the network.  So I learn, 
  1. Fetching the URL from the QR Code is being done within the browser
  2. I have to just launch these pages and use the QR Code images to fetch the data out of it
    • No need for internet here
    • And moreover, there is no remote address at all; then why the internet is needed to upload images!
  3. This tells me, could be JavaScript is doing the job here!
    • It is a key learning from my so far observations
Now, I look at the Console to see if I can find more hints to my test investigation.



Diving into Console and JavaScript


In the Console, 
  1. For qareader dot online, I see:
    • Couldn't find enough finder patterns (found 0)
  2. For helloacm dot com/tools/qrcode-reader/, I see
    • Couldn't find enough finder patterns

Pic: Message on qrreader dot com



Pic: Message on helloacm dot com



This is the source of the problem -- the QR Code could not be decoded.  If the Finder Patterns are not identifiable in the QR Code, then data in the QR Code cannot be decoded.  I see "found 0" in the console log.

But, why the Finder Patterns are not identified in this case though it is seen in an image by the human eyes?  This is the start of the actual test investigation and debugging for the behavior experienced.

Further, I learn both these websites make use of the same JavaScript -- llqrcode.jsAnother key learning!  I see this JavaScript is copyrighted to Lazar Laszlo.  And, I found another website that scans the QR Code image -- webqr dot com.  I experience the same behavior on uploading the TTC QR Code here as well, that is the message -- error decoding QR Code.  The same text and in the same format!



Pic: Message on webqr dot com



Reading through the below JavaScript, I make few more observations.


Pic: llqrcode.js

I learn:
  1. When the image is about to be decoded
    • It is taken as a 2D image
    • The height and width of the QR Code image are collected and calculated
      • The check is made if they are appropriate to consume and process further
  2. In the process function,
    • The QR Code is converted to a grayscale image
      • The grayscale is the usual one that we see around us in black-and-white
  3. Now trying to look for Finding Patterns,
    • Looks like it is executing the condition if (h < 3)
      • So the message in console -- Couldn't find enough finder patterns
    • As a result, the decoding of QR is returning message -- error decoding QR Code
This information tells me, there is something to do with the QR Code shared by the TTC.  But, how come it works on smartphone apps?  

I have not attempted to fetch the code from the smartphone app and analyze it at this point in time of testing.  I make an assumption -- could be the program used in the smartphone app can identify the Finder Patterns irrespective of the color and shape in the QR Code.

I had made an observation documented in the beginning -- the Finder Pattern is in oval shape and not in the concentric square shape.



Testing the Tests


I picked the QR Code image shared by the TTC and converted it to a grayscale image.  I used this grayscale image in the above said three websites.  I see the same message -- error decoding QR Code.

I picked the registration form URL that I had got by scanning QR Code using the mobile app.  I generated the QR Code and uploaded it to these three websites.  I see the QR Code decoded successfully now; I see the Google Form URL to register.  Note that, if I turn off the internet and use a valid QR Code, I see the URL.

This tells me, there is no problem with Google Form URL accessibility or encoding or decoding.  It is to do with the QR Code shared by TTC.


Pic: QR Code shared by TTC



Pic: Grayscale QR Code generated by me


Pic: QR Code generated by me with Google Form URL




Pic: QR Code on qrreader dot online on uploading TTC QR Code




Pic: QR Code on webqr dot com on uploading TTC QR Code


The dimension and size of the QR Code image file shared by TTC are not the same as the one generated by JavaScript.  I see pixelation and a bit of distortion in the QR Code generated by JavaScript using TTC QR Code.  

Look at the Pattern Finders in the QR Code from JavaScript; compare it with the QR Code shared by the TTC.  They don't look the same.


Understanding the QR Code


QR stands for Quick Response.  QR Code was pioneered by Masahiro Hara at Japanese company Denso-Wave in 1990.  QR code has different sections and Finding Patterns is one.

I find information on these web pages useful:
  • https://www.explainthatstuff.com/how-data-matrix-codes-work.html
  • http://qrcode.meetheed.com/question14.php
  • http://www.keepautomation.com/tips/qr_code/functions_of_qr_code_function_patterns.html.


So, What's the Problem Here?


From the inferences I'm making from my tests so far, it looks like
  1. The QR Code from TTC has data (shape and color) that cannot be processed by this JavaScript?
    • Not very sure!
    • But the so far analysis says yes with the code read
  2. Need to generate more customized QR Code
    • If possible include Finding Patterns in different geometric shapes -- primary suspect
    • Then rule out or point in if that's the problem source
    • If this is not the problem, then
      • The dimensions of the QR Code image file is the problem?
        • For now, this is the second suspect
          • But, the read JavaScript code does not say this
Need to understand how the mobile app code can read it successfully.  Then figure out the differences in the mobile app code and the JavaScript referred here.

I'm stopping my testing for now.
I can test! I test!