Drupal 8 supports multiple ways to test your code, which gives developers the confidence to change functionality and ensure that regressions are caught early.
This session will introduce attendees to the following methods in Drupal 8 for providing test coverage:
Unit Tests
Kernel Tests
Functional Tests
Behavioral Tests
We will discuss when to use each kind of test, and how to handle potentially frustrating situations.
Code samples: https://github.com/ebeyrent/apod
Workshop: Functional testing made easy with PHPUnit & Selenium (phpCE Poland,...Ondřej Machulda
Annotated slides for phpCE workshop on November 3, 2017.
Workshop repository: https://github.com/OndraM/selenium-workshop-phpce
The workshop covered:
- setting up local development environment (using Docker)
- practical examples of functional tests implementation
- exploring possibilities of Selenium WebDriver
- parallel test execution using Steward
- hands-on Page Object design pattern
- dealing with asynchronous elements of web-pages (AJAX, JavaScript)
- general tips & tricks how to keep a maintainable suite of functional tests in a long-term
Selenium & PHPUnit made easy with Steward (Berlin, April 2017)Ondřej Machulda
Annotated slides from Berlin PHP Usergroup Meetup, 4th April 2017.
---
Not only unit tests but also end-to-end tests in real browser are important part of test automation and test pyramid. So let's have a look how to easily write and run Selenium functional tests using PHPUnit and Steward.
Automated php unit testing in drupal 8Jay Friendly
An overview of PHPUnit Automated testing in Drupal 8, including a comparison of manual testing vs automated testing, the pros and cons of automated testing, and the types of automated tests available in Drupal 8.
Key items of the presentation will be:
What is PHPUnit
Whats new in testing in Drupal 8
Core Classes and Components
Core/ Contibuted modules
PHPUnit file structure, namespace, and required metadata
Running PHPUnit tests.
Available tools for running automated tests.
Test all the things! Automated testing with Drupal 8Sam Becker
With Drupal 8 released, one of the most important aspects of building a website or module has changed dramatically for the better. Developers now have a myriad of tools at their disposal to be able to test their code. If you are interested in improving your code and preventing bugs, but are unfamiliar with acronyms like BTB, KTB and WTB, this session is for you. If you’ve dabbled in testing but haven’t explored the depths of PHPUnit or Mink, then this session is for you.
We all know that PHPunit testing framework has been added into Drupal 8. More than that SimpleTest in Drupal 8 is deprecated now. PHP unit testing also helps you to check you business logic So let's learn and discuss about, how to write the PHPUnit test for our requirement.
Workshop: Functional testing made easy with PHPUnit & Selenium (phpCE Poland,...Ondřej Machulda
Annotated slides for phpCE workshop on November 3, 2017.
Workshop repository: https://github.com/OndraM/selenium-workshop-phpce
The workshop covered:
- setting up local development environment (using Docker)
- practical examples of functional tests implementation
- exploring possibilities of Selenium WebDriver
- parallel test execution using Steward
- hands-on Page Object design pattern
- dealing with asynchronous elements of web-pages (AJAX, JavaScript)
- general tips & tricks how to keep a maintainable suite of functional tests in a long-term
Selenium & PHPUnit made easy with Steward (Berlin, April 2017)Ondřej Machulda
Annotated slides from Berlin PHP Usergroup Meetup, 4th April 2017.
---
Not only unit tests but also end-to-end tests in real browser are important part of test automation and test pyramid. So let's have a look how to easily write and run Selenium functional tests using PHPUnit and Steward.
Automated php unit testing in drupal 8Jay Friendly
An overview of PHPUnit Automated testing in Drupal 8, including a comparison of manual testing vs automated testing, the pros and cons of automated testing, and the types of automated tests available in Drupal 8.
Key items of the presentation will be:
What is PHPUnit
Whats new in testing in Drupal 8
Core Classes and Components
Core/ Contibuted modules
PHPUnit file structure, namespace, and required metadata
Running PHPUnit tests.
Available tools for running automated tests.
Test all the things! Automated testing with Drupal 8Sam Becker
With Drupal 8 released, one of the most important aspects of building a website or module has changed dramatically for the better. Developers now have a myriad of tools at their disposal to be able to test their code. If you are interested in improving your code and preventing bugs, but are unfamiliar with acronyms like BTB, KTB and WTB, this session is for you. If you’ve dabbled in testing but haven’t explored the depths of PHPUnit or Mink, then this session is for you.
We all know that PHPunit testing framework has been added into Drupal 8. More than that SimpleTest in Drupal 8 is deprecated now. PHP unit testing also helps you to check you business logic So let's learn and discuss about, how to write the PHPUnit test for our requirement.
Test any (yes, any) website using NightwatchJS - selenium based JavaScript test runner. We will cover
- prerequisites
- configuration
- writing tests
- reading reports
- continuous integration and services
An intro to nightwatch(a tool to create and run functional tests, e2e tests using selenium in the background) and examples of cases, also how to integrate nightwatch to a Continous Integration tool
Describes Outside-In development and Behvaiour Driven Development. Illustrates basic Cucumber usage within a Rails app and then goes over more advanced topics such as JS as web services.
Testing frontends with nightwatch & saucelabsTudor Barbu
Sooner or later, any application needs to be released. And before that, it needs to be tested. Ideally!
The purpose of this talk is to explore Nightwatch as a testing framework, how to set up an automated CI system using Travis and using SauceLabs as a browser farm.
See for code https://github.com/motanelu/bcn-js-news-widget
Cover the advantages of test driven development, the reasons for pushing it all the way to the browser level, and then explore the options for testing JavaScript, look at some examples, and then integrate the tests into our existing development workflow.
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.
This is the slides I used when I shared my humble insight on Django to the students in University of Taipei in 2016. Please feel free to correct me if there is anything wrong.
Three Simple Chords of Alternative PageObjects and Hardcore of LoadableCompon...Iakiv Kramarenko
***VIDEO***: view in SD at http://youtu.be/HPHKeBakulQ or download in HD at http://bit.ly/1nyvA67
Often we have lack of automation resources. If we just would involve less experienced juniors to implement test model and even Manual QA to write DSL like tests…
In this talk I want to present the simplified approach to write PageObjects for your test model as it would be like playing “three chords” song on a guitar. And also share the experience of pacifying the LoadableComponent pattern, rather hard in implementation but making your tests much more DRY and easy to use in context of loading pages.
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
Test any (yes, any) website using NightwatchJS - selenium based JavaScript test runner. We will cover
- prerequisites
- configuration
- writing tests
- reading reports
- continuous integration and services
An intro to nightwatch(a tool to create and run functional tests, e2e tests using selenium in the background) and examples of cases, also how to integrate nightwatch to a Continous Integration tool
Describes Outside-In development and Behvaiour Driven Development. Illustrates basic Cucumber usage within a Rails app and then goes over more advanced topics such as JS as web services.
Testing frontends with nightwatch & saucelabsTudor Barbu
Sooner or later, any application needs to be released. And before that, it needs to be tested. Ideally!
The purpose of this talk is to explore Nightwatch as a testing framework, how to set up an automated CI system using Travis and using SauceLabs as a browser farm.
See for code https://github.com/motanelu/bcn-js-news-widget
Cover the advantages of test driven development, the reasons for pushing it all the way to the browser level, and then explore the options for testing JavaScript, look at some examples, and then integrate the tests into our existing development workflow.
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.
This is the slides I used when I shared my humble insight on Django to the students in University of Taipei in 2016. Please feel free to correct me if there is anything wrong.
Three Simple Chords of Alternative PageObjects and Hardcore of LoadableCompon...Iakiv Kramarenko
***VIDEO***: view in SD at http://youtu.be/HPHKeBakulQ or download in HD at http://bit.ly/1nyvA67
Often we have lack of automation resources. If we just would involve less experienced juniors to implement test model and even Manual QA to write DSL like tests…
In this talk I want to present the simplified approach to write PageObjects for your test model as it would be like playing “three chords” song on a guitar. And also share the experience of pacifying the LoadableComponent pattern, rather hard in implementation but making your tests much more DRY and easy to use in context of loading pages.
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
Leveling Up With Unit Testing - LonghornPHP 2022Mark Niebergall
Writing unit testing on a project can seem like a daunting task, and earning team and leadership buy-in can be challenging. Level up your skillset as we cover PHPUnit and Prophecy setup with composer, writing meaningful tests, restructuring existing classes with dependency injection to allow for unit testing, using mock objects, and releasing code confidently with test coverage. We'll also discuss overcoming common biases, unit testing challenges, and shortcomings of unit testing.
In July 2004 David Heinemeier Hansson aka dhh, a Danish programmer came up with a web application framework while building a project management tool named Basecamp. In 2012 it is now one of the fastest growing web frameworks in world. Tens of Thousands Rails applications like Basecamp, Twitter, Github, Groupon, and our own (in Bangladesh) akhoni.com and bdipo.com are live. Ruby on Rails (RoR) claims to be a breakthrough in lowering the barriers of entry to programming. Powerful web applications that formerly took months to develop can be produced now in a days. RoR is now official platform for many startup incubators. In this session we will introduce and explore the zeal of RoR. We will see how this can optimize programmer's happiness and sustainable productivity.
This was presented in Basis Softexpo 2012 and arranged by Nascenia IT, the leading Ruby on Rails development company in Bangladesh.
A quick talk that was given during 2010 about the main features of Play! framework.
This was given to the development team at Evoolv, which has kickstarted the web development over Play! framework which turned out was a decent choice.
Drupal 8 Every Day: An Intro to Developing With Drupal 8Acquia
Drupal 8 is coming, everyone is excited, and your developers can’t wait to use all the shiny new features. There’s just one problem: you still need to get your daily work done. Every day Drupal development requires the execution of many common patterns and scenarios.
How well do these common scenarios translate to Drupal 8? We polled Drupal developers to find what tasks we do the most and built a practical guide to using Drupal 8 in every day development.
In this presentation we’ll cover the following real world scenarios, while sprinkling in Drupal 8 best practices along the way:
- Configuration Management
- Creating and altering pages and forms
- Menu callback patterns
- Managing dependencies
In this talk, Carlos de la Guardia shows how a Pyramid application can be deployed using a front end web server, like Apache or Nginx. He also covers how to automate deployment using buildout and a PyPI clone, and post-deployment creation of a variety of maintenance scripts and cron jobs that perform application specific tasks through Pyramid.
A link to audio of the presentation is here: http://2011ploneconference.sched.org/event/29a2f357905e4ab0fe3048c53bc1c94c
Continuous Integration with Open Source Tools - PHPUgFfm 2014-11-20Michael Lihs
Presentation about open source tools to set up continuous integration and continuous deployment. Covers Git, Gitlab, Chef, Vagrant, Jenkins, Gatling, Dashing, TYPO3 Surf and some other tools. Shows some best practices for testing with Behat and Functional Testing.
Slide del corso di AngularJs Intermediate tenuto da LinkMe. Si affronteranno argomenti come l’estensione dell’html tramite direttive, la gestione di chiamate a un server API, crud e non solo, gestione di errori del server, validazione di form e alcuni principi del testing automatico.
Android UI Testing with Appium
This presentation covers:
- how appium works
- setting up test development environment with AndroidStudio
- running tests
- UI automation best practices
- common problems with automation
{ JSON:API} 2 - A Path to Decoupled DrupalErich Beyrent
With the inclusion of JSON:API in Drupal core, we now have a solid, stable path to support decoupled Drupal through standardization of payload structures and query string parameters.
This session will cover:
Why JSON:API instead of the REST module, GraphQL, Relaxed WS, etc.
JSON:API overview
Authentication with JSON Web Tokens
Requests, filters, sorting, pagination
File uploads
Gotchas
Configuration as Dependency: Managing Drupal 8 Configuration with git and Com...Erich Beyrent
Drupal 8 provides a robust configuration management system which represents a paradigm shift from previous versions of Drupal. It's now easier than ever to represent your configuration in code and manage it with source control. However, that may not be enough.
This session will propose a new strategy for thinking about Drupal 8 configuration, treating it as just another dependency, managed the same way code dependencies are managed with Composer.
We'll cover:
Drupal 8 configuration management overview
New ways of managing your git repository
Composer and Drupal Console
Drupal 8 multisite considerations
Digital Mayflower - Data Pilgrimage with the Drupal Migrate ModuleErich Beyrent
In the year 1620, a collection of data left their proprietary database in search of a new, open ecosystem. Okay, so maybe that's not quite how the story goes, but it works for a modern reboot of the classic saga.
That moment of panic when someone assigns you the task of migrating a legacy site into Drupal. It's a daunting project, fraught with undocumented data, mixed character sets, bizarre content modules, and impossible deadlines. Fortunately, it's now easier than ever to migrate data from an existing source into Drupal, thanks to the Migrate module.
In this session, we'll cover:
An overview of the Migrate module
Common hooks for iterating and transforming your data
Migration from databases, CSV files, and static HTML
How to use Drush to control your migrations
Staging Drupal: Change Management Strategies for DrupalErich Beyrent
This is a presentation I gave at DrupalCamp NH in October 2011. The presentation covered aspects of change management strategies across multiple server environments.
Navigating the Metaverse: A Journey into Virtual Evolution"Donna Lenk
Join us for an exploration of the Metaverse's evolution, where innovation meets imagination. Discover new dimensions of virtual events, engage with thought-provoking discussions, and witness the transformative power of digital realms."
Custom Healthcare Software for Managing Chronic Conditions and Remote Patient...Mind IT Systems
Healthcare providers often struggle with the complexities of chronic conditions and remote patient monitoring, as each patient requires personalized care and ongoing monitoring. Off-the-shelf solutions may not meet these diverse needs, leading to inefficiencies and gaps in care. It’s here, custom healthcare software offers a tailored solution, ensuring improved care and effectiveness.
Paketo Buildpacks : la meilleure façon de construire des images OCI? DevopsDa...Anthony Dahanne
Les Buildpacks existent depuis plus de 10 ans ! D’abord, ils étaient utilisés pour détecter et construire une application avant de la déployer sur certains PaaS. Ensuite, nous avons pu créer des images Docker (OCI) avec leur dernière génération, les Cloud Native Buildpacks (CNCF en incubation). Sont-ils une bonne alternative au Dockerfile ? Que sont les buildpacks Paketo ? Quelles communautés les soutiennent et comment ?
Venez le découvrir lors de cette session ignite
How to Position Your Globus Data Portal for Success Ten Good PracticesGlobus
Science gateways allow science and engineering communities to access shared data, software, computing services, and instruments. Science gateways have gained a lot of traction in the last twenty years, as evidenced by projects such as the Science Gateways Community Institute (SGCI) and the Center of Excellence on Science Gateways (SGX3) in the US, The Australian Research Data Commons (ARDC) and its platforms in Australia, and the projects around Virtual Research Environments in Europe. A few mature frameworks have evolved with their different strengths and foci and have been taken up by a larger community such as the Globus Data Portal, Hubzero, Tapis, and Galaxy. However, even when gateways are built on successful frameworks, they continue to face the challenges of ongoing maintenance costs and how to meet the ever-expanding needs of the community they serve with enhanced features. It is not uncommon that gateways with compelling use cases are nonetheless unable to get past the prototype phase and become a full production service, or if they do, they don't survive more than a couple of years. While there is no guaranteed pathway to success, it seems likely that for any gateway there is a need for a strong community and/or solid funding streams to create and sustain its success. With over twenty years of examples to draw from, this presentation goes into detail for ten factors common to successful and enduring gateways that effectively serve as best practices for any new or developing gateway.
How Recreation Management Software Can Streamline Your Operations.pptxwottaspaceseo
Recreation management software streamlines operations by automating key tasks such as scheduling, registration, and payment processing, reducing manual workload and errors. It provides centralized management of facilities, classes, and events, ensuring efficient resource allocation and facility usage. The software offers user-friendly online portals for easy access to bookings and program information, enhancing customer experience. Real-time reporting and data analytics deliver insights into attendance and preferences, aiding in strategic decision-making. Additionally, effective communication tools keep participants and staff informed with timely updates. Overall, recreation management software enhances efficiency, improves service delivery, and boosts customer satisfaction.
Globus Compute wth IRI Workflows - GlobusWorld 2024Globus
As part of the DOE Integrated Research Infrastructure (IRI) program, NERSC at Lawrence Berkeley National Lab and ALCF at Argonne National Lab are working closely with General Atomics on accelerating the computing requirements of the DIII-D experiment. As part of the work the team is investigating ways to speedup the time to solution for many different parts of the DIII-D workflow including how they run jobs on HPC systems. One of these routes is looking at Globus Compute as a way to replace the current method for managing tasks and we describe a brief proof of concept showing how Globus Compute could help to schedule jobs and be a tool to connect compute at different facilities.
TROUBLESHOOTING 9 TYPES OF OUTOFMEMORYERRORTier1 app
Even though at surface level ‘java.lang.OutOfMemoryError’ appears as one single error; underlyingly there are 9 types of OutOfMemoryError. Each type of OutOfMemoryError has different causes, diagnosis approaches and solutions. This session equips you with the knowledge, tools, and techniques needed to troubleshoot and conquer OutOfMemoryError in all its forms, ensuring smoother, more efficient Java applications.
Globus Connect Server Deep Dive - GlobusWorld 2024Globus
We explore the Globus Connect Server (GCS) architecture and experiment with advanced configuration options and use cases. This content is targeted at system administrators who are familiar with GCS and currently operate—or are planning to operate—broader deployments at their institution.
Software Engineering, Software Consulting, Tech Lead.
Spring Boot, Spring Cloud, Spring Core, Spring JDBC, Spring Security,
Spring Transaction, Spring MVC,
Log4j, REST/SOAP WEB-SERVICES.
Prosigns: Transforming Business with Tailored Technology SolutionsProsigns
Unlocking Business Potential: Tailored Technology Solutions by Prosigns
Discover how Prosigns, a leading technology solutions provider, partners with businesses to drive innovation and success. Our presentation showcases our comprehensive range of services, including custom software development, web and mobile app development, AI & ML solutions, blockchain integration, DevOps services, and Microsoft Dynamics 365 support.
Custom Software Development: Prosigns specializes in creating bespoke software solutions that cater to your unique business needs. Our team of experts works closely with you to understand your requirements and deliver tailor-made software that enhances efficiency and drives growth.
Web and Mobile App Development: From responsive websites to intuitive mobile applications, Prosigns develops cutting-edge solutions that engage users and deliver seamless experiences across devices.
AI & ML Solutions: Harnessing the power of Artificial Intelligence and Machine Learning, Prosigns provides smart solutions that automate processes, provide valuable insights, and drive informed decision-making.
Blockchain Integration: Prosigns offers comprehensive blockchain solutions, including development, integration, and consulting services, enabling businesses to leverage blockchain technology for enhanced security, transparency, and efficiency.
DevOps Services: Prosigns' DevOps services streamline development and operations processes, ensuring faster and more reliable software delivery through automation and continuous integration.
Microsoft Dynamics 365 Support: Prosigns provides comprehensive support and maintenance services for Microsoft Dynamics 365, ensuring your system is always up-to-date, secure, and running smoothly.
Learn how our collaborative approach and dedication to excellence help businesses achieve their goals and stay ahead in today's digital landscape. From concept to deployment, Prosigns is your trusted partner for transforming ideas into reality and unlocking the full potential of your business.
Join us on a journey of innovation and growth. Let's partner for success with Prosigns.
SOCRadar Research Team: Latest Activities of IntelBrokerSOCRadar
The European Union Agency for Law Enforcement Cooperation (Europol) has suffered an alleged data breach after a notorious threat actor claimed to have exfiltrated data from its systems. Infamous data leaker IntelBroker posted on the even more infamous BreachForums hacking forum, saying that Europol suffered a data breach this month.
The alleged breach affected Europol agencies CCSE, EC3, Europol Platform for Experts, Law Enforcement Forum, and SIRIUS. Infiltration of these entities can disrupt ongoing investigations and compromise sensitive intelligence shared among international law enforcement agencies.
However, this is neither the first nor the last activity of IntekBroker. We have compiled for you what happened in the last few days. To track such hacker activities on dark web sources like hacker forums, private Telegram channels, and other hidden platforms where cyber threats often originate, you can check SOCRadar’s Dark Web News.
Stay Informed on Threat Actors’ Activity on the Dark Web with SOCRadar!
Accelerate Enterprise Software Engineering with PlatformlessWSO2
Key takeaways:
Challenges of building platforms and the benefits of platformless.
Key principles of platformless, including API-first, cloud-native middleware, platform engineering, and developer experience.
How Choreo enables the platformless experience.
How key concepts like application architecture, domain-driven design, zero trust, and cell-based architecture are inherently a part of Choreo.
Demo of an end-to-end app built and deployed on Choreo.
In software engineering, the right architecture is essential for robust, scalable platforms. Wix has undergone a pivotal shift from event sourcing to a CRUD-based model for its microservices. This talk will chart the course of this pivotal journey.
Event sourcing, which records state changes as immutable events, provided robust auditing and "time travel" debugging for Wix Stores' microservices. Despite its benefits, the complexity it introduced in state management slowed development. Wix responded by adopting a simpler, unified CRUD model. This talk will explore the challenges of event sourcing and the advantages of Wix's new "CRUD on steroids" approach, which streamlines API integration and domain event management while preserving data integrity and system resilience.
Participants will gain valuable insights into Wix's strategies for ensuring atomicity in database updates and event production, as well as caching, materialization, and performance optimization techniques within a distributed system.
Join us to discover how Wix has mastered the art of balancing simplicity and extensibility, and learn how the re-adoption of the modest CRUD has turbocharged their development velocity, resilience, and scalability in a high-growth environment.
First Steps with Globus Compute Multi-User EndpointsGlobus
In this presentation we will share our experiences around getting started with the Globus Compute multi-user endpoint. Working with the Pharmacology group at the University of Auckland, we have previously written an application using Globus Compute that can offload computationally expensive steps in the researcher's workflows, which they wish to manage from their familiar Windows environments, onto the NeSI (New Zealand eScience Infrastructure) cluster. Some of the challenges we have encountered were that each researcher had to set up and manage their own single-user globus compute endpoint and that the workloads had varying resource requirements (CPUs, memory and wall time) between different runs. We hope that the multi-user endpoint will help to address these challenges and share an update on our progress here.
Check out the webinar slides to learn more about how XfilesPro transforms Salesforce document management by leveraging its world-class applications. For more details, please connect with sales@xfilespro.com
If you want to watch the on-demand webinar, please click here: https://www.xfilespro.com/webinars/salesforce-document-management-2-0-smarter-faster-better/
7. Why write automated tests?
❖ Manual testing can be generally cheaper, especially for a
short-term project (i.e. one-time testing)
❖ Manual testing is BORING AF
❖ Manual testing is time-consuming for projects that
iterate
❖ Manual testing is hard to make exactly repeatable,
requires extensive documentation
9. Why write automated tests?
❖ Better to discover bugs during local development and
build processes
❖ Gives developers the confidence to make changes
❖ Some tests are self-documenting*
10. Unit Tests
❖ Individual methods are tested as discrete units
❖ Unit tests are solitary
❖ Uses test doubles, or mocks to control behavior of
related components
❖ Unit tests are fast, no need to bootstrap Drupal
11. Unit Tests
❖ Unit tests go in my_module/tests/src/Unit
❖ Unit tests require a namespace in the form of
DrupalTestsmy_moduleUnit
❖ Unit tests should include the following annotations:
❖ Class:
❖ @coversDefaultClass - Specified the name of the class being tests
❖ @group - Specifies the group of tests, usually the name of your
module
❖ Method:
❖ @covers - Specifies the class method being tested
12. public function __construct() {
$this->httpClient = Drupal::service('httpd_client');
$this->logger = Drupal::logger('apod');
$this->config = Drupal::config('apod.api_config');
}
public function getAstronomyPictureOfTheDay() {
$uri = $this->addQueryString(
$this->url, ['query' => [
'api_key' => $this->config->get(‘api_key')
]]);
$response = $this->httpClient->request('GET', $uri);
return $this->handleResponse($response);
}
18. Kernel Tests
❖ Kernel tests are sociable
❖ Used when it’s not practical or easy to write mocks
❖ Kernel tests are executed in a minimal Drupal environment
❖ Tests have access to the database and files
❖ Tests must install dependent modules
❖ Kernel tests are slower than unit tests, because they need to
bootstrap Drupal.
19. Kernel Tests
❖ Kernel tests go in my_module/tests/src/Kernel
❖ Kernel tests require a namespace in the form of
DrupalTestsmy_moduleKernel
25. Functional Tests
❖ Also known as integration tests, or UI tests
❖ Integration tests balance out the expense of speed vs
confidence
❖ Integration tests are supported in Drupal 8 as Browser
tests and Javascript tests
26. Browser Tests
❖ Browser tests use a fully installed Drupal environment
❖ All required modules must be declared
❖ Tests use an internal web browser behind the scene
❖ Tests tend to run much slower than unit tests
❖ Javascript is not supported
27. Browser Tests
❖ Browser tests go in my_module/tests/src/Functional
❖ Browser tests require a namespace in the form of
DrupalTestsmy_moduleFunctional
❖ Unit tests should include the following annotations:
❖ Class:
❖ @group - Specifies the group of tests, usually the
name of your module
28. Browser Tests
$ cd web
$ ../vendor/bin/phpunit -c ./core/phpunit.xml.dist
modules/custom/my_module/tests/src/Functional/MyTest.php
30. Javascript Tests
❖ Javascript tests go in my_module/tests/src/
FunctionalJavascript
❖ Browser tests require a namespace in the form of
DrupalTestsmy_moduleFunctionalJavascript
❖ Unit tests should include the following annotations:
❖ Class:
❖ @group - Specifies the group of tests, usually the
name of your module
31. Javascript Tests
❖ Tests require PhantomJS to run
❖ Uses a full Drupal installation
❖ Can be used to test AJAX functionality
❖ There is no UI
❖ Debugging occurs using a debugger
32. Javascript Tests
Install PhantomJS: http://phantomjs.org/download.html
Run PhantomJS:
$ phantomjs --ssl-protocol=any --ignore-ssl-errors=true --debug=true
./vendor/jcalderonzumba/gastonjs/src/Client/main.js
8510 1024 768
Run tests:
$ cd web
$ ../vendor/bin/phpunit -c ./core/phpunit.xml.dist
modules/custom/apod/tests/src/FunctionalJavascript/
ApodBlockHtmlTest.php
34. Behavioral Tests
❖ Behat FTW!
❖ Gherkin is human readable, and self-documenting
❖ Behat runs in a full local browser (IE, Firefox, Chrome)
❖ Debugging is simple and easy
38. Tests Help Drive Development
❖ Before starting a feature, translate requirements to
Gherkin
❖ Before starting a class, stub out methods and associated
unit tests
❖ Add functionality and tests concurrently
❖ Before marking a project as done, make sure all tests
pass
39. Gotchas
❖ Unit tests may need rewrites after refactoring code
❖ Modules need to be enabled for tests (other than unit tests)
to run
❖ Schema can cause problems.
❖ $this->strictConfigSchema = FALSE;
❖ Traits can cause problems.
❖ $object->setStringTranslation($this-
>getStringTranslationStub())
❖ Debugging in PhantomJS isn’t fun.
40. Gotchas
❖ Permissions can cause problems (run tests as Apache
user)
❖ Traits can cause problems.
// Solution
$object->setStringTranslation($this->getStringTranslationStub());
41. Summary
❖ Unit tests are for testing class methods.
❖ Kernel tests are for testing APIs
❖ Functional and behavioral tests are for testing web
interfaces.
❖ Behat is amazing