The document discusses avoiding abuse of static methods in test automation frameworks. It provides examples of issues with static methods like concurrency problems and mutable state. It recommends using object-oriented principles and dependency injection frameworks instead. Dependency injection allows injecting dependencies into objects rather than hardcoding them, improving test isolation, readability and maintainability. The document gives examples of implementing dependency injection with Spring by using annotations like @Autowired and @Component. It also provides references for more information on inversion of control, dependency injection and static methods.
ATAGTR2017 Upgrading a mobile tester's weapons with advanced debuggingAgile Testing Alliance
The presentation on Upgrading a mobile tester's weapons with advanced debugging was done during #ATAGTR2017, one of the largest global testing conference. All copyright belongs to the author.
Author and presenter : Abhijeet Vaikar
These are training slides created by me to conduct training and knowledge sharing sessions for beginners in Cognizant Technology Solutions for Selenium Automation.
Main instruments used for Web UI test automation.
Drivers: Selenium WebDriver, Sikuli X.
Frameworks: PageFactory, TestNG.
Other tools: Apache Ant, Jenkins CI.
Automated UI testing done right (DDDSydney)Mehdi Khalili
Many teams try Automated UI Testing and many fail. Automated UI Testing is hard: the tests take a lot of time to write and tend to be brittle and hard to maintain. In this session I will provide you with some practical advice on how to and how not to write your tests introducing you to some UI testing ideas, patterns and frameworks that will help you write your tests faster while making them less brittle and easier to maintain.
This is an action packed session for testing enthusiasts.
UI Testing Best Practices - An Expected JourneyOren Farhi
This slide focus on the good reasons for writing unit tests for testing ui.
Much like you're testing ui manually, you can have simple minimal code doing that for you.
ATAGTR2017 Upgrading a mobile tester's weapons with advanced debuggingAgile Testing Alliance
The presentation on Upgrading a mobile tester's weapons with advanced debugging was done during #ATAGTR2017, one of the largest global testing conference. All copyright belongs to the author.
Author and presenter : Abhijeet Vaikar
These are training slides created by me to conduct training and knowledge sharing sessions for beginners in Cognizant Technology Solutions for Selenium Automation.
Main instruments used for Web UI test automation.
Drivers: Selenium WebDriver, Sikuli X.
Frameworks: PageFactory, TestNG.
Other tools: Apache Ant, Jenkins CI.
Automated UI testing done right (DDDSydney)Mehdi Khalili
Many teams try Automated UI Testing and many fail. Automated UI Testing is hard: the tests take a lot of time to write and tend to be brittle and hard to maintain. In this session I will provide you with some practical advice on how to and how not to write your tests introducing you to some UI testing ideas, patterns and frameworks that will help you write your tests faster while making them less brittle and easier to maintain.
This is an action packed session for testing enthusiasts.
UI Testing Best Practices - An Expected JourneyOren Farhi
This slide focus on the good reasons for writing unit tests for testing ui.
Much like you're testing ui manually, you can have simple minimal code doing that for you.
Test automation - Building effective solutionsArtem Nagornyi
This presentation is answering the questions: how to build an effective test automation framework, select the right tools and organize to whole process?
Introductory overview of testing techniques for web application development. Explains where different testing methods fit in to the software development cycle.
Confused by testing terms and jargon? This talk walks through testing web applications, explaining the difference between unit testing and end to end testing. Several tools and concepts are also explored through a demo section.
Sample projects can be found at https://github.com/sethmcl/testing_web_applications.
Selenium is a software testing framework for automating tests of Web applications. Join Frank Cohen for a Workshop to learn the basics of Selenium. A screencast for this presentation is on the PushToTest.com Web site.
ForwardJS 2017 - Fullstack end-to-end Test Automation with node.jsMek Srunyu Stittri
Slide deck for ForwardJS 2017 in San Francisco - March 1st 2017
https://forwardjs.com/schedule#lecture-224
Airware builds hardware, software and cloud for commercial drones. We have transitioned to Node.js for cloud functional test automation in 2015. The purpose of this is to unite Fullstack developers and Automation engineers to speak in the same language which is JavaScript. With a year worth of lessons learnt, we will share the challenges involved with building a full-stack test automation framework with Node.js while using the latest and greatest in JavaScript tools.
Slides done for the talk on CodeCeption given during the April London Yii Meetup.
The full screencast of the talk can be viewed here: https://www.youtube.com/watch?v=FclV9ML7bH4
WinAppDriver - Windows Store Apps Test AutomationJeremy Kao
Introduce the background and initial implementation of WinAppDriver - WebDriver for Windows Applications, including desktop applications, store apps (formerly known as Metro-style apps).
Test automation - Building effective solutionsArtem Nagornyi
This presentation is answering the questions: how to build an effective test automation framework, select the right tools and organize to whole process?
Introductory overview of testing techniques for web application development. Explains where different testing methods fit in to the software development cycle.
Confused by testing terms and jargon? This talk walks through testing web applications, explaining the difference between unit testing and end to end testing. Several tools and concepts are also explored through a demo section.
Sample projects can be found at https://github.com/sethmcl/testing_web_applications.
Selenium is a software testing framework for automating tests of Web applications. Join Frank Cohen for a Workshop to learn the basics of Selenium. A screencast for this presentation is on the PushToTest.com Web site.
ForwardJS 2017 - Fullstack end-to-end Test Automation with node.jsMek Srunyu Stittri
Slide deck for ForwardJS 2017 in San Francisco - March 1st 2017
https://forwardjs.com/schedule#lecture-224
Airware builds hardware, software and cloud for commercial drones. We have transitioned to Node.js for cloud functional test automation in 2015. The purpose of this is to unite Fullstack developers and Automation engineers to speak in the same language which is JavaScript. With a year worth of lessons learnt, we will share the challenges involved with building a full-stack test automation framework with Node.js while using the latest and greatest in JavaScript tools.
Slides done for the talk on CodeCeption given during the April London Yii Meetup.
The full screencast of the talk can be viewed here: https://www.youtube.com/watch?v=FclV9ML7bH4
WinAppDriver - Windows Store Apps Test AutomationJeremy Kao
Introduce the background and initial implementation of WinAppDriver - WebDriver for Windows Applications, including desktop applications, store apps (formerly known as Metro-style apps).
Modular Test-driven SPAs with Spring and AngularJSGunnar Hillert
Single-page Applications (SPA) are all the rage these days and with them there is an avalanche of new tools, libraries and frameworks we need to know. But what does this mean for us as Spring developers? In this session we will give you an overview of the current landscape and illustrate the choices the Spring XD team has made for its user interface. What do I use to write SPA applications? How do I integrate them into existing Spring-based backends? How do I build them? Can I integrate them into my existing Gradle or Maven build processes in order to achieve complete build automation? How do I integrate realtime messaging using Spring's SockJS/WebSocket support? In this talk we will answer these and many more questions. We will cover frameworks such as AngularJS, Bootstrap, RequireJS; tools like Bower, Grunt, Gulp; and also talk about testing using Karma and Protractor.
Mastering Test Automation: How To Use Selenium SuccessfullySpringPeople
In this slide, identify what to test and choose the best language for automation. Learn to write maintainable and reusable Selenium tests and add UI layout test as part of automation using Galen framework. This slide will also guide you in reporting structure by using external plugin's, an illustration covering cross browser testing (Running selenium grid with Docker) and explain Code repository (Git) and Jenkins CI tool.
The slides I was using when delivering my talk about how to develop hybrid applications using WordPress.
More information about the FED course I deliver can be found at fed.course.lifemichael.com
Developing ASP.NET Applications Using the Model View Controller Patterngoodfriday
Learn how to use the model-view-controller (MVC) pattern to take advantage of your favorite .NET Framework language for writing business logic in a way that is de-coupled from the views of the data.
Good practices for debugging Selenium and Appium testsAbhijeet Vaikar
We often come across situations when:
> We cannot figure out why our Selenium/Appium scripts fail during execution either locally or on CI.
> We need to debug scripts locally while writing them but find debugging painful and slow
Debugging the scripts is often the approach to fix them. What all different ways we can do it?
I shared about some of the good practices I have used for debugging Selenium and Appium scripts
Upgrading Mobile Tester's Weapons with Advanced DebuggingAbhijeet Vaikar
I presented this paper at Global Testing Retreat 2017 conference. This paper describes benefits, methods, and approach for performing advanced debugging of mobile web, hybrid and native apps, as an additional check in mobile testing.
Launch Your Streaming Platforms in MinutesRoshan Dwivedi
The claim of launching a streaming platform in minutes might be a bit of an exaggeration, but there are services that can significantly streamline the process. Here's a breakdown:
Pros of Speedy Streaming Platform Launch Services:
No coding required: These services often use drag-and-drop interfaces or pre-built templates, eliminating the need for programming knowledge.
Faster setup: Compared to building from scratch, these platforms can get you up and running much quicker.
All-in-one solutions: Many services offer features like content management systems (CMS), video players, and monetization tools, reducing the need for multiple integrations.
Things to Consider:
Limited customization: These platforms may offer less flexibility in design and functionality compared to custom-built solutions.
Scalability: As your audience grows, you might need to upgrade to a more robust platform or encounter limitations with the "quick launch" option.
Features: Carefully evaluate which features are included and if they meet your specific needs (e.g., live streaming, subscription options).
Examples of Services for Launching Streaming Platforms:
Muvi [muvi com]
Uscreen [usencreen tv]
Alternatives to Consider:
Existing Streaming platforms: Platforms like YouTube or Twitch might be suitable for basic streaming needs, though monetization options might be limited.
Custom Development: While more time-consuming, custom development offers the most control and flexibility for your platform.
Overall, launching a streaming platform in minutes might not be entirely realistic, but these services can significantly speed up the process compared to building from scratch. Carefully consider your needs and budget when choosing the best option for you.
Introducing Crescat - Event Management Software for Venues, Festivals and Eve...Crescat
Crescat is industry-trusted event management software, built by event professionals for event professionals. Founded in 2017, we have three key products tailored for the live event industry.
Crescat Event for concert promoters and event agencies. Crescat Venue for music venues, conference centers, wedding venues, concert halls and more. And Crescat Festival for festivals, conferences and complex events.
With a wide range of popular features such as event scheduling, shift management, volunteer and crew coordination, artist booking and much more, Crescat is designed for customisation and ease-of-use.
Over 125,000 events have been planned in Crescat and with hundreds of customers of all shapes and sizes, from boutique event agencies through to international concert promoters, Crescat is rigged for success. What's more, we highly value feedback from our users and we are constantly improving our software with updates, new features and improvements.
If you plan events, run a venue or produce festivals and you're looking for ways to make your life easier, then we have a solution for you. Try our software for free or schedule a no-obligation demo with one of our product specialists today at crescat.io
Graspan: A Big Data System for Big Code AnalysisAftab Hussain
We built a disk-based parallel graph system, Graspan, that uses a novel edge-pair centric computation model to compute dynamic transitive closures on very large program graphs.
We implement context-sensitive pointer/alias and dataflow analyses on Graspan. An evaluation of these analyses on large codebases such as Linux shows that their Graspan implementations scale to millions of lines of code and are much simpler than their original implementations.
These analyses were used to augment the existing checkers; these augmented checkers found 132 new NULL pointer bugs and 1308 unnecessary NULL tests in Linux 4.4.0-rc5, PostgreSQL 8.3.9, and Apache httpd 2.2.18.
- Accepted in ASPLOS ‘17, Xi’an, China.
- Featured in the tutorial, Systemized Program Analyses: A Big Data Perspective on Static Analysis Scalability, ASPLOS ‘17.
- Invited for presentation at SoCal PLS ‘16.
- Invited for poster presentation at PLDI SRC ‘16.
Code reviews are vital for ensuring good code quality. They serve as one of our last lines of defense against bugs and subpar code reaching production.
Yet, they often turn into annoying tasks riddled with frustration, hostility, unclear feedback and lack of standards. How can we improve this crucial process?
In this session we will cover:
- The Art of Effective Code Reviews
- Streamlining the Review Process
- Elevating Reviews with Automated Tools
By the end of this presentation, you'll have the knowledge on how to organize and improve your code review proces
AI Pilot Review: The World’s First Virtual Assistant Marketing SuiteGoogle
AI Pilot Review: The World’s First Virtual Assistant Marketing Suite
👉👉 Click Here To Get More Info 👇👇
https://sumonreview.com/ai-pilot-review/
AI Pilot Review: Key Features
✅Deploy AI expert bots in Any Niche With Just A Click
✅With one keyword, generate complete funnels, websites, landing pages, and more.
✅More than 85 AI features are included in the AI pilot.
✅No setup or configuration; use your voice (like Siri) to do whatever you want.
✅You Can Use AI Pilot To Create your version of AI Pilot And Charge People For It…
✅ZERO Manual Work With AI Pilot. Never write, Design, Or Code Again.
✅ZERO Limits On Features Or Usages
✅Use Our AI-powered Traffic To Get Hundreds Of Customers
✅No Complicated Setup: Get Up And Running In 2 Minutes
✅99.99% Up-Time Guaranteed
✅30 Days Money-Back Guarantee
✅ZERO Upfront Cost
See My Other Reviews Article:
(1) TubeTrivia AI Review: https://sumonreview.com/tubetrivia-ai-review
(2) SocioWave Review: https://sumonreview.com/sociowave-review
(3) AI Partner & Profit Review: https://sumonreview.com/ai-partner-profit-review
(4) AI Ebook Suite Review: https://sumonreview.com/ai-ebook-suite-review
A Study of Variable-Role-based Feature Enrichment in Neural Models of CodeAftab Hussain
Understanding variable roles in code has been found to be helpful by students
in learning programming -- could variable roles help deep neural models in
performing coding tasks? We do an exploratory study.
- These are slides of the talk given at InteNSE'23: The 1st International Workshop on Interpretability and Robustness in Neural Software Engineering, co-located with the 45th International Conference on Software Engineering, ICSE 2023, Melbourne Australia
OpenMetadata Community Meeting - 5th June 2024OpenMetadata
The OpenMetadata Community Meeting was held on June 5th, 2024. In this meeting, we discussed about the data quality capabilities that are integrated with the Incident Manager, providing a complete solution to handle your data observability needs. Watch the end-to-end demo of the data quality features.
* How to run your own data quality framework
* What is the performance impact of running data quality frameworks
* How to run the test cases in your own ETL pipelines
* How the Incident Manager is integrated
* Get notified with alerts when test cases fail
Watch the meeting recording here - https://www.youtube.com/watch?v=UbNOje0kf6E
Mobile App Development Company In Noida | Drona InfotechDrona Infotech
Looking for a reliable mobile app development company in Noida? Look no further than Drona Infotech. We specialize in creating customized apps for your business needs.
Visit Us For : https://www.dronainfotech.com/mobile-application-development/
GraphSummit Paris - The art of the possible with Graph TechnologyNeo4j
Sudhir Hasbe, Chief Product Officer, Neo4j
Join us as we explore breakthrough innovations enabled by interconnected data and AI. Discover firsthand how organizations use relationships in data to uncover contextual insights and solve our most pressing challenges – from optimizing supply chains, detecting fraud, and improving customer experiences to accelerating drug discoveries.
AI Fusion Buddy Review: Brand New, Groundbreaking Gemini-Powered AI AppGoogle
AI Fusion Buddy Review: Brand New, Groundbreaking Gemini-Powered AI App
👉👉 Click Here To Get More Info 👇👇
https://sumonreview.com/ai-fusion-buddy-review
AI Fusion Buddy Review: Key Features
✅Create Stunning AI App Suite Fully Powered By Google's Latest AI technology, Gemini
✅Use Gemini to Build high-converting Converting Sales Video Scripts, ad copies, Trending Articles, blogs, etc.100% unique!
✅Create Ultra-HD graphics with a single keyword or phrase that commands 10x eyeballs!
✅Fully automated AI articles bulk generation!
✅Auto-post or schedule stunning AI content across all your accounts at once—WordPress, Facebook, LinkedIn, Blogger, and more.
✅With one keyword or URL, generate complete websites, landing pages, and more…
✅Automatically create & sell AI content, graphics, websites, landing pages, & all that gets you paid non-stop 24*7.
✅Pre-built High-Converting 100+ website Templates and 2000+ graphic templates logos, banners, and thumbnail images in Trending Niches.
✅Say goodbye to wasting time logging into multiple Chat GPT & AI Apps once & for all!
✅Save over $5000 per year and kick out dependency on third parties completely!
✅Brand New App: Not available anywhere else!
✅ Beginner-friendly!
✅ZERO upfront cost or any extra expenses
✅Risk-Free: 30-Day Money-Back Guarantee!
✅Commercial License included!
See My Other Reviews Article:
(1) AI Genie Review: https://sumonreview.com/ai-genie-review
(2) SocioWave Review: https://sumonreview.com/sociowave-review
(3) AI Partner & Profit Review: https://sumonreview.com/ai-partner-profit-review
(4) AI Ebook Suite Review: https://sumonreview.com/ai-ebook-suite-review
#AIFusionBuddyReview,
#AIFusionBuddyFeatures,
#AIFusionBuddyPricing,
#AIFusionBuddyProsandCons,
#AIFusionBuddyTutorial,
#AIFusionBuddyUserExperience
#AIFusionBuddyforBeginners,
#AIFusionBuddyBenefits,
#AIFusionBuddyComparison,
#AIFusionBuddyInstallation,
#AIFusionBuddyRefundPolicy,
#AIFusionBuddyDemo,
#AIFusionBuddyMaintenanceFees,
#AIFusionBuddyNewbieFriendly,
#WhatIsAIFusionBuddy?,
#HowDoesAIFusionBuddyWorks
Essentials of Automations: The Art of Triggers and Actions in FMESafe Software
In this second installment of our Essentials of Automations webinar series, we’ll explore the landscape of triggers and actions, guiding you through the nuances of authoring and adapting workspaces for seamless automations. Gain an understanding of the full spectrum of triggers and actions available in FME, empowering you to enhance your workspaces for efficient automation.
We’ll kick things off by showcasing the most commonly used event-based triggers, introducing you to various automation workflows like manual triggers, schedules, directory watchers, and more. Plus, see how these elements play out in real scenarios.
Whether you’re tweaking your current setup or building from the ground up, this session will arm you with the tools and insights needed to transform your FME usage into a powerhouse of productivity. Join us to discover effective strategies that simplify complex processes, enhancing your productivity and transforming your data management practices with FME. Let’s turn complexity into clarity and make your workspaces work wonders!
May Marketo Masterclass, London MUG May 22 2024.pdfAdele Miller
Can't make Adobe Summit in Vegas? No sweat because the EMEA Marketo Engage Champions are coming to London to share their Summit sessions, insights and more!
This is a MUG with a twist you don't want to miss.
AI Genie Review: World’s First Open AI WordPress Website CreatorGoogle
AI Genie Review: World’s First Open AI WordPress Website Creator
👉👉 Click Here To Get More Info 👇👇
https://sumonreview.com/ai-genie-review
AI Genie Review: Key Features
✅Creates Limitless Real-Time Unique Content, auto-publishing Posts, Pages & Images directly from Chat GPT & Open AI on WordPress in any Niche
✅First & Only Google Bard Approved Software That Publishes 100% Original, SEO Friendly Content using Open AI
✅Publish Automated Posts and Pages using AI Genie directly on Your website
✅50 DFY Websites Included Without Adding Any Images, Content Or Doing Anything Yourself
✅Integrated Chat GPT Bot gives Instant Answers on Your Website to Visitors
✅Just Enter the title, and your Content for Pages and Posts will be ready on your website
✅Automatically insert visually appealing images into posts based on keywords and titles.
✅Choose the temperature of the content and control its randomness.
✅Control the length of the content to be generated.
✅Never Worry About Paying Huge Money Monthly To Top Content Creation Platforms
✅100% Easy-to-Use, Newbie-Friendly Technology
✅30-Days Money-Back Guarantee
See My Other Reviews Article:
(1) TubeTrivia AI Review: https://sumonreview.com/tubetrivia-ai-review
(2) SocioWave Review: https://sumonreview.com/sociowave-review
(3) AI Partner & Profit Review: https://sumonreview.com/ai-partner-profit-review
(4) AI Ebook Suite Review: https://sumonreview.com/ai-ebook-suite-review
#AIGenieApp #AIGenieBonus #AIGenieBonuses #AIGenieDemo #AIGenieDownload #AIGenieLegit #AIGenieLiveDemo #AIGenieOTO #AIGeniePreview #AIGenieReview #AIGenieReviewandBonus #AIGenieScamorLegit #AIGenieSoftware #AIGenieUpgrades #AIGenieUpsells #HowDoesAlGenie #HowtoBuyAIGenie #HowtoMakeMoneywithAIGenie #MakeMoneyOnline #MakeMoneywithAIGenie
Quarkus Hidden and Forbidden ExtensionsMax Andersen
Quarkus has a vast extension ecosystem and is known for its subsonic and subatomic feature set. Some of these features are not as well known, and some extensions are less talked about, but that does not make them less interesting - quite the opposite.
Come join this talk to see some tips and tricks for using Quarkus and some of the lesser known features, extensions and development techniques.
2. Hello!
I am Abhijeet Vaikar
● Software Quality Engineer since 6 years and 7
months with a focus on Test Automation
● Quality Engineer @ Carousell
● https://www.linkedin.com/in/abhijeetvaikar/
3. Southeast Asia's largest and fastest
growing mobile marketplace,
and a highly-rated iPhone & Android app
that makes selling as simple as taking a
photo and buying as simple as chat.
https://www.carousell.com
4. What are we here for?
● Why we should avoid abusing static methods in
automation frameworks
● What we can do about it.
● How we can use Dependency Injection
frameworks to simplify automation scripts.
7. Does this look familiar?
protected void grabScreenshot(){
ScreenshotUtil.captureScreenshot(currentSuiteScreenshotsDirector
yPath);
}
AppiumUtil.scrollDown();
User user = UserService.getUser(expectedUserKey);
8. Does this look familiar?
itemName =
TestDataService.extract(itemName);
private static
AndroidDriver<WebElement> driver;
10. Concurrency issues
All static objects are shared between threads. Imagine the race condition issues with
parallel test executions.
private static WebDriver driver;
private static HashMap<String, String> testResultsMap;
Thread 1
Thread 2 Thread 3
Expect something :)
Get something else :’(
11. Design
Code becomes procedural instead of object oriented.
public class LoginTest {
@Test(priority = 0)
public void loginfail() {
LoginPage.goTo("http://127.0.0.1:8080/login");
LoginPage.loginAs("wrong username", "wrongpassword");
boolean didLoginFail = LoginPage.loginErrorDisplayed();
Assert.assertTrue(didLoginFail == true, "Bad login was successful");
if (didLoginFail){
LoginPage.getLoginErrorMessage();
}
}
@Test(priority = 1)
public void loginsuccess() {
LoginPage.loginAs("correct_username", "correctpass");
boolean didLoginFail = LoginPage.loginErrorDisplayed();
Assert.assertTrue(didLoginFail == false, "Valid Login was unsuccessful");
}
12. Mutable state
Static objects if kept mutable leaves their values open to change by other code.
/** Contains all the constant system property names */
public final class SystemPropertyConstants {
public static String loginEndPoint = "/api/login/";
}
// In some other code
SystemPropertyConstants.loginEndPoint = "/api/logout/";
14. “Make the framework smart so that the
test code can be short and simple.
Test code must be so concise that it
doesn't matter which language is used to
run it”
- Martin Schneider ( Java Ninja @
Carousell )
15. For concurrency issues
public static ThreadLocal<WebDriver> driver;
driver =
new ThreadLocal<WebDriver>() {
@Override
protected WebDriver initialValue() {
return new FirefoxDriver(); // You
can use other driver based on your requirement.
}
};
OR use Dependency Injection with non-static object
16. Design
Use Object-Oriented programming concepts (abstraction, encapsulation, inheritance, polymorphism) to make your
test code maintainable.
new AuthPage().login("username","password");
SellingPage sellingPage = new HomePage().startSelling();
sellingPage
.setCategory(Category.EVERYTHING_ELSE)
.setItemDetails("Carousell Test Item",ConditionType.NEW,"Test Description")
.setPrice("10.12")
.setDealDetails(DealType.MEETUP,"Lets meetup at 5 PM")
.listIt();
AND enhance them using Dependency Injection
17. Mutable state
To avoid static objects being overwritten by other code, declare them final
/** Contains all the constant system property names */
public final class SystemPropertyConstants {
public static final String loginEndPoint = "/api/login/";
}
18. What is
Dependency
Injection????
Dependency Injection
Dependency Non-Injection
public class Employee {
private Address address;
public Employee() {
address = new Address();
}
}
Employee employee = new Employee(new address);
Employee employee = new Employee();
employee.setAddress(new Address());
19. SellingPage sellingPage = new SellingPage(driver);
// Injecting driver dependency in pageobjects
@BeforeMethod
public void setUp(ITestContext testContext){
...
}
// DI used by TestNG
20. Dependency Injection using a framework
● Use a DI framework instead of managing dependencies manually.
● DI frameworks: Spring, Google Guice, PicoContainer, Dagger
● These frameworks use IoC (Inversion of Control) container in which all the
dependencies are registered, initialized and managed.
● IoC (Inversion of Control) - “Don’t call us, we call you”
● Once the dependencies are instantiated, the container injects them using
approaches like:
○ Constructor injection
○ Setter method injection
○ Field injection
21. Benefits of Dependency Injection
● Single Responsibility Principle
● Clean, Readable code
● Isolated components which become easy for testing as dependencies can be
mocked without modifying depending class.
22. How
we can use Dependency Injection frameworks to simplify automation scripts.
22
23. Spring Dependency Injection
Spring IoC Container
(where all the magic
happens!)
Configuration in Java
class or XML
Read dependency and configuration details
Create dependency
objects and inject them
POJOs/ Java
Classes part of your
application
code/test code
Usable system with
all dependencies
available
24. @Component @Configuration
@Autowired @Bean
Applied to fields, setter methods, and
constructors. The @Autowired annotation
injects object dependency implicitly.
Used as config for
Spring. Can have
methods to instantiate
and configure the
dependencies
Marks the Java class
as a bean or
component (i.e., you
want Spring to
manage this class
instance)
Applied to fields, setter methods, and
constructors. The @Autowired annotation
injects object dependency implicitly.
Commonly used annotations in Spring
Used for conditional
loading of classes
based on usecase
(environment,
platform etc)
@Profile
25. @Test()
public void testNewListingAppearsInSearch() throws Exception {
new WelcomePage(driver).beginSignUpOrLoginWithEmail();
new AuthPage(driver).login("username","password");
new
HomePage(driver).startSellingWithPhotoFromCamera();
new CameraPage(driver).capturePhoto();
new CameraPhotoPreviewEditPage(driver).moveForward();
}
}
● Driver is a dependency for PageObjects.
● PageObjects are a dependency for the test class
(Is it necessary to create new instance of pageobject every time?)
27. @Configuration
@ComponentScan(basePackages = "com.carousell")
public class SpringContext {
@Autowired
private TestConfiguration configuration;
private WebDriver driver;
@Bean
public WebDriver getWebDriver() {
if(configuration.isWeb()){
driver = new ChromeDriver();
}
else if(configuration.isAndroid() {
driver = new AndroidDriver();
}
else if(configuration.isIOS()) {
driver = new IOSDriver();
}
return driver;
}
Create a configuration class for Spring to manage dependencies
28. public class WelcomePage extends BasePage {
@Autowired
private WebDriver driver;
//You can move this to BasePage too
. . . .
}
30. @Autowired
WelcomePage welcomePage;
@Autowired
AuthPage authPage;
. . . . .
@Test()
public void testNewListingAppearsInSearch() throws Exception {
welcomPage.beginSignUpOrLoginWithEmail();
authPage.login("username","password");
homePage.startSellingWithPhotoFromCamera();
cameraPage.capturePhoto();
cameraPhotoPreviewEditPage.moveForward();
//Use references directly as they are already injected with instance by
Spring
}
31. public abstract class WelcomePage
extends BasePage {
}
@Component
@Profile(Platform.ANDROID)
public class AndroidWelcomePage
extends WelcomePage {
}
@Component
@Profile(Platform.IOS)
public class IOSWelcomePage
extends WelcomePage {
}
spring.profiles.active=ANDROID - Initializes AndroidWelcomePage and injects into an
Autowired variable.
32. Sounds good. Where can I find real
world implementation of such
framework?
Check out https://www.justtestlah.qa/
35. Reference
Inversion of Control and Dependency Injection
https://martinfowler.com/bliki/InversionOfControl.html
https://martinfowler.com/articles/injection.html
https://www.baeldung.com/inversion-control-and-dependency-injection-in-spring
https://dzone.com/articles/a-guide-to-spring-framework-annotations
https://stackoverflow.com/questions/52720198/how-does-spring-profile-work-with-inheritance
Static methods and variables
https://stackoverflow.com/questions/7026507/why-are-static-variables-considered-evil
https://stackoverflow.com/questions/2671496/java-when-to-use-static-methods
https://stackoverflow.com/questions/4002201/why-arent-static-methods-considered-good-oo-practice
https://softwareengineering.stackexchange.com/questions/336701/static-services-and-testability
Use of Dependency Injection in automation frameworks
www.justtestlah.qa by Martin Schneider
https://peterkedemo.wordpress.com/2013/03/30/writing-good-selenium-tests-with-page-objects-and-spring/
Editor's Notes
Static objects represent global state and scope-less.
this is just the tip of the iceberg that Spring offers. It's grown to become much more than a framework, Spring is actually an entire application development ecosystem. We only use spring-core to get the Spring container.
Whether or not to use Spring in a testing framework depends on multiple factors, for example what other functionality is needed (for example, Spring has a good way of accessing web services). You could mention that Spring is not the most lightweight solution but one that's been around for many years and quite well maintained. Also chances are that engineers have experience with it (plus the experience they gain by using it is more valuable than e.g. just knowing Cucumber DI).