<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Sabarish Sasidharan</title>
    <description>The latest articles on DEV Community by Sabarish Sasidharan (@sabariiish).</description>
    <link>https://dev.to/sabariiish</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F419424%2F643a3590-7d2b-49e8-babd-31861ae9d1e8.PNG</url>
      <title>DEV Community: Sabarish Sasidharan</title>
      <link>https://dev.to/sabariiish</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/sabariiish"/>
    <language>en</language>
    <item>
      <title>Should you use BDD for API testing?</title>
      <dc:creator>Sabarish Sasidharan</dc:creator>
      <pubDate>Sat, 07 May 2022 23:53:47 +0000</pubDate>
      <link>https://dev.to/sabariiish/should-you-use-bdd-for-api-testing-koe</link>
      <guid>https://dev.to/sabariiish/should-you-use-bdd-for-api-testing-koe</guid>
      <description>&lt;p&gt;BDD is a collaboration practice: you describe business rules, examples of these rules, and acceptance criteria that illustrate these rules. Some of these acceptance criteria can be potentially automated. &lt;/p&gt;

&lt;p&gt;Detailed API testing (e.g. testing CRUD functionalities, error codes, JSON format etc.) is rarely of much interest to the business, so it generally makes little sense to use Gherkin to express them - it just adds an extra layer of complexity. Lower level tools such as RestAssured do the job just fine. And testing REST APIs with any JavaScript test library is pretty trivial. So if your team finds it more efficient to write REST API tests with a tool like Karate, that's great! But it ain't BDD, and it's not the only game in town.&lt;/p&gt;

&lt;p&gt;The only exception is where you might use Cucumber as a communication tool between developers across teams, as a more expressive way to describe and document API contracts. But you can do this with contract testing tools as well, though it may not be as readable. &lt;/p&gt;

&lt;p&gt;Let me know your thoughts in the comments!&lt;/p&gt;

</description>
      <category>bdd</category>
      <category>testing</category>
    </item>
    <item>
      <title>Wiremock on Heroku cloud!</title>
      <dc:creator>Sabarish Sasidharan</dc:creator>
      <pubDate>Thu, 17 Sep 2020 18:41:17 +0000</pubDate>
      <link>https://dev.to/sabariiish/wiremock-on-heroku-cloud-19li</link>
      <guid>https://dev.to/sabariiish/wiremock-on-heroku-cloud-19li</guid>
      <description>&lt;p&gt;&lt;strong&gt;Wiremock&lt;/strong&gt;: WireMock is an HTTP mock server. At its core it is web server that can be primed to serve canned responses to particular requests (stubbing) and that captures incoming requests so that they can be checked later (verification).&lt;/p&gt;

&lt;p&gt;A core feature of WireMock is the ability to return canned HTTP responses for requests matching criteria. &lt;/p&gt;

&lt;p&gt;It can be used as a library by any JVM application, or run as a standalone process either on the same host as the system under test or a remote server.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Heroku&lt;/strong&gt;: Heroku is a cloud platform as a service (PaaS) supporting several programming languages&lt;/p&gt;

&lt;p&gt;The Heroku network runs the customer's apps in virtual containers which execute on a reliable runtime environment. Heroku calls these containers "Dynos." These Dynos can run code written in Node, Ruby, PHP, Go, Scala, Python, Java, or Clojure. Heroku also provides custom buildpacks with which the developer can deploy apps in any language. Heroku lets the developer scale the app instantly by either increasing the number of dynos or by changing the type of dyno the app runs in.&lt;/p&gt;

&lt;p&gt;Setup Wiremock on Heroku&lt;/p&gt;

&lt;p&gt;1)  Create a free Heroku account (&lt;a href="https://signup.heroku.com/dc"&gt;https://signup.heroku.com/dc&lt;/a&gt;)&lt;br&gt;
2)  Install Heroku CLI - &lt;a href="https://devcenter.heroku.com/articles/heroku-cli"&gt;https://devcenter.heroku.com/articles/heroku-cli&lt;/a&gt;&lt;br&gt;
3)  Create an application in the Heroku cloud (You can use CLI or the UI dashboard)&lt;br&gt;
4)  Using Heroku CLI install the java plugin: &lt;code&gt;$ heroku plugins:install java&lt;/code&gt;&lt;br&gt;
5)  Deploy Wiremock:&lt;br&gt;
a.  Using Build Pack: Refer &lt;a href="https://github.com/gpratte/wiremock-deploy-heroku"&gt;https://github.com/gpratte/wiremock-deploy-heroku&lt;/a&gt; to use the &lt;a href="http://www.energizedwork.com/"&gt;Energized Work&lt;/a&gt; downloadable jar buildpack.&lt;br&gt;
b.  Without Build Pack: &lt;br&gt;
i.  Refer &lt;a href="https://github.com/sabariish/wiremock-deploy-heroku"&gt;https://github.com/sabariish/wiremock-deploy-heroku&lt;/a&gt; and obseve the Procfile. &lt;br&gt;
ii. In the deploy tab for the Heroku application created connect the the above git hub repo&lt;br&gt;
iii.    Hit Deploy Branch or setup automatic deploys&lt;br&gt;
6)  Access the Wiremock deployed @ &lt;a href=""&gt;https://{appname}.herokuapp.com/__admin/mappings&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;See &lt;a href="https://github.com/sabariish/wiremock/blob/master/src/test/java/wiremock/mock/ExampleTest.java"&gt;https://github.com/sabariish/wiremock/blob/master/src/test/java/wiremock/mock/ExampleTest.java&lt;/a&gt; for couple of tests which run on a hosted wiremock instance.&lt;/p&gt;

&lt;p&gt;exampleTest – Runs a simple test which sets up a mock service (stateless rest call)&lt;br&gt;
exampleScenario – Example of a &lt;a href="http://wiremock.org/docs/stateful-behaviour/"&gt;stateful&lt;/a&gt; request  &lt;/p&gt;

&lt;p&gt;References: &lt;a href="http://wiremock.org/docs/"&gt;http://wiremock.org/docs/&lt;/a&gt;&lt;/p&gt;

</description>
    </item>
    <item>
      <title>Service Virtualization for Digital Transformation</title>
      <dc:creator>Sabarish Sasidharan</dc:creator>
      <pubDate>Wed, 29 Jul 2020 00:09:33 +0000</pubDate>
      <link>https://dev.to/sabariiish/service-virtualization-for-digital-transformation-1398</link>
      <guid>https://dev.to/sabariiish/service-virtualization-for-digital-transformation-1398</guid>
      <description>&lt;p&gt;Testing in a modern microservices architecture is a nightmare of dependencies. You’re ready to deploy, but the Payment Gateway Sandbox is down, the Legacy Mainframe team is 'refreshing data,' and the Auth API isn't even built yet.&lt;/p&gt;

&lt;p&gt;Service Virtualization (SV) isn't just a fancy mock; it’s the difference between shipping today and waiting two weeks for a dependency to wake up.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Why?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;It addresses how to shift left efficiently in an iterative development methodology by providing a way out from:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Unavailable Services (External systems)&lt;/li&gt;
&lt;li&gt;Dependent Services (under development)&lt;/li&gt;
&lt;li&gt;Unavailable Data (Need to generate test data to test the scenario under construction)&lt;/li&gt;
&lt;li&gt;Inconsistent Environment (No environment to deploy complete ecosystem)&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fs3zzg67z0c91fknxs13s.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fs3zzg67z0c91fknxs13s.png" alt="Alt Text" width="800" height="347"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Service Virtualization allows us to create a simulated version of a service helping to develop system interactions independently in an isolated environment. Simply playback an expected response and see how the system works. Configure complex test conditions using stubbed responses which otherwise would be near impossible to test in a live environment due to several dependent factors.&lt;/p&gt;

&lt;p&gt;Most of the time we are unable to test an edge case scenario due to unavailability of data. Service Virtualization allows us to generate and stub responses which would help emulate such edge case scenarios. Moreover the onus is a stable and reliable contract generated to test such scenarios consistently every release.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;What to virtualize?&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;The service is costly to use.&lt;/li&gt;
&lt;li&gt;The service is available only for limited timeframes.&lt;/li&gt;
&lt;li&gt;The service is needed by multiple teams.&lt;/li&gt;
&lt;li&gt;The service is being developed.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;If the answers to these questions is a Yes, then such services should be considered for Virtualization.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Can I virtualize every system interaction?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Yes. However, be cautious while doing so! If the virtualization is at the services layer, sure, but if you are having to execute scripted and compiled code outside of your application then consider not to. &lt;/p&gt;

&lt;p&gt;Avoid keeping counts in a virtual service. Let's consider a banking domain use case where you want to validate that a user’s account activity screen gets updated when you transfer money between two accounts. What you can simulate easily is a user's experience of transfer money, or validate account activity screen displays the required field as per requirement in isolation. However you will need extra code to simulate that the amount which was transferred is getting reflected in the user’s account activity. This involves managing states of the services which does transfer money and the one which is used to get account details information. In case of stubs, the account details service stub will always send the response with a balance when the response was recorded. You can update the value in the response based on the state captured from transfer money, but that means you are writing additional code to update which should not be the intention of service virtualization. &lt;/p&gt;

&lt;p&gt;Can you do this? Yes. But I would not recommend managing states between services. Break down the use case and validate the intent of the service and the behaviour in isolation.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Mocks vs Virtual Service:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Although mocks and virtual service are used interchangeably, there are differences between the two. Both serve the same purpose but in different forms and phases.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2F5udapwrf71ptsvvsc462.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2F5udapwrf71ptsvvsc462.png" alt="Alt Text" width="800" height="354"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Benefits:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2F5qxtk3mbpw5608koag2s.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2F5qxtk3mbpw5608koag2s.png" alt="Alt Text" width="800" height="336"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Reduced dependency on internal teams or third parties.&lt;/li&gt;
&lt;li&gt;Isolate behaviors in a shorter time frame&lt;/li&gt;
&lt;li&gt;Eliminate the need to build infrastructure for every feature/scrum team per release&lt;/li&gt;
&lt;li&gt;Enabling CI by enabling continuous test data and continuous test environments&lt;/li&gt;
&lt;li&gt;Run realistic and quantifiable Performance tests&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Challenges:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fbmtqp88vjrs9l8tsexpz.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fbmtqp88vjrs9l8tsexpz.png" alt="Alt Text" width="800" height="303"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Tools:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Examples of few tools available for Service Virtualization in the market:&lt;br&gt;
&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Ft2tamshdx1y87e45anwo.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Ft2tamshdx1y87e45anwo.png" alt="Alt Text" width="800" height="160"&gt;&lt;/a&gt;&lt;br&gt;
Tool Comparisons: &lt;a href="https://trafficparrot.com/Service_virtualization_and_stubbing_tools_comparison.html" rel="noopener noreferrer"&gt;https://trafficparrot.com/Service_virtualization_and_stubbing_tools_comparison.html&lt;/a&gt;&lt;br&gt;
&lt;a href="https://www.softwaretestinghelp.com/service-virtualization-tools/" rel="noopener noreferrer"&gt;https://www.softwaretestinghelp.com/service-virtualization-tools/&lt;/a&gt;&lt;/p&gt;

</description>
      <category>digitaltransformation</category>
    </item>
    <item>
      <title>Achieving effective Continuous Testing with Behavior Driven Development </title>
      <dc:creator>Sabarish Sasidharan</dc:creator>
      <pubDate>Mon, 29 Jun 2020 22:52:40 +0000</pubDate>
      <link>https://dev.to/sabariiish/achieving-effective-continuous-testing-with-behavior-driven-development-5h52</link>
      <guid>https://dev.to/sabariiish/achieving-effective-continuous-testing-with-behavior-driven-development-5h52</guid>
      <description>&lt;p&gt;&lt;strong&gt;Continuous Testing&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;The goal of continuous testing is to provide fast and continuous feedback on the level of business risk, allowing for a rapid go/no go decision on the feature delivery.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Motivation:&lt;/strong&gt;&lt;br&gt;
• Risks are exposed as soon as they are introduced&lt;br&gt;
• Prevent those problems from progressing to the next stage of SDLC&lt;br&gt;
• Reduce time and effort for finding and fixing defects&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Challenges:&lt;/strong&gt;&lt;br&gt;
One of the major impediments achieving an efficient continuous testing outcome is Test Design. &lt;br&gt;
Business/PO’s make go/no go decision based on the user journey. The disconnect happens when:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;tests are developed without an understanding of the business context. &lt;/li&gt;
&lt;li&gt;tests designed either based on requirements or to test the unit of code. &lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Testing should be a collaborative effort of Dev, QA, and Business, aligned with priorities of the line of business. Remember: &lt;strong&gt;Quality is everybody’s responsibility!&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;What is BDD?&lt;/strong&gt;&lt;br&gt;
BDD enables software teams to work in collaboration deriving business value. This allows us to build a shared understanding of the work being done. Teams use domain-specific language and produce system documentation based on this shared understanding. &lt;/p&gt;

&lt;p&gt;Example:&lt;br&gt;
&lt;strong&gt;Feature:&lt;/strong&gt; Consumer Credit Card Application&lt;br&gt;
&lt;strong&gt;Scenario:&lt;/strong&gt; Reject credit card application if the applicant’s credit score is less than 450&lt;br&gt;
&lt;strong&gt;Given&lt;/strong&gt; An individual applied for a credit card from an affiliate corporate site&lt;br&gt;
&lt;strong&gt;When&lt;/strong&gt; the individual has a credit score of less than 450&lt;br&gt;
&lt;strong&gt;Then&lt;/strong&gt; reject the credit card application with an error message&lt;br&gt;
&lt;strong&gt;And&lt;/strong&gt; show suggestions for secured-card options.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;a href="https://cucumber.io/docs/bdd/?sbsearch=What%20is%20BDD"&gt;https://cucumber.io/docs/bdd/?sbsearch=What%20is%20BDD&lt;/a&gt;&lt;/strong&gt; describes in detail the essential three-step activity as an iterative process to achieve an executable specification deriving business value. Note the Discovery and Formulation phases. At the end of the formulation phase, there should be multiple readable acceptance criteria as part of the Definition of Ready for the user story.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Anti-Pattern:&lt;/strong&gt;&lt;br&gt;
&lt;strong&gt;Feature:&lt;/strong&gt; CreditCardApplication API&lt;br&gt;
&lt;strong&gt;Scenario:&lt;/strong&gt; Validate submitCreditCardApplication returns ‘LOW_CREDIT_SCORE’ code for credit score &amp;lt; 450&lt;br&gt;
&lt;strong&gt;Given&lt;/strong&gt; the client sends submitCreditCardApplication a message &lt;br&gt;
&lt;strong&gt;And&lt;/strong&gt; getCreditScore api returns applicant.score.value less than 450&lt;br&gt;
&lt;strong&gt;Then&lt;/strong&gt; return status code 404 with error code “LOW_CREDIT_SCORE”&lt;br&gt;
&lt;strong&gt;And&lt;/strong&gt; the response has section applicant.misc.suggestions &lt;/p&gt;

&lt;p&gt;The above is an anti-pattern because the scenario does not describe the business value. A product owner or a business unit owner may find difficulty at deriving the value it provides to the product even though it is ultimately testing the obvious rules (per dev/qa technical team members).&lt;br&gt;
Most often the Dev/SDET/QE ends up writing the anti-pattern as the intention is to test the underlying code or business rule.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;How does Continuous Testing benefit from BDD?&lt;/strong&gt;&lt;br&gt;
Ideally, all tests should be executed across all non-production test environments. All tests need to be run at some point in the build pipeline, but not all tests need to be run all the time. &lt;br&gt;
Testing must begin early; it must be logically componentized and must be executed continuously.&lt;/p&gt;

&lt;p&gt;BDD feature files allow the business to pick on tests that prioritize the business value and those can serve as the minimum tests which should be run on a per commit basis. If the tests are too technical to read and do not throw light on the underlying business value then you end up with the temptation of running all the tests or do not understand what the failure of the test means to the product, hence makes it difficult to make an informed and quick go/no go decision. You still run all your Unit Tests, but the user journey tests can be prioritized in a local/dev environment. A similar Test selection needs to be done for each upstream environment the build is promoted.&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--x7Xkm7n_--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/dbr9moxv1436zj8stvvo.PNG" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--x7Xkm7n_--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/dbr9moxv1436zj8stvvo.PNG" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;BDD way allows the team to compartmentalize the application and derive logical tests focusing user journey.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Artifacts produced by Continuous Testing process:&lt;/strong&gt;&lt;br&gt;
• List of actionable tasks&lt;br&gt;
• Metrics on the quality of the process leading to continuous improvement&lt;/p&gt;

&lt;p&gt;Continuous testing should be able to achieve predictability. It should help understand the impact of a change "early". Predictability, in turn, will pave the way to be faster in repetitions.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Gotcha's:&lt;/strong&gt; (For another day)&lt;br&gt;
• Heavy reliance on manual and/or automated “GUI” tests. (Emphasize on API Tests)&lt;br&gt;
• Test execution process (Lack of Dynamic Test Automation)&lt;br&gt;
• Test environment and Test data constraints (Service Virtualization); &lt;br&gt;
• Test infrastructure&lt;/p&gt;

</description>
      <category>bdd</category>
      <category>testautomation</category>
      <category>selenium</category>
      <category>cicd</category>
    </item>
  </channel>
</rss>
