This document provides an agenda and objectives for a tutorial on implementing an automated dependency injection framework in a dynamic language like JavaScript. The tutorial will first cover setting up the development environment. It will then demonstrate manual dependency injection in a tic-tac-toe game. Next, it will discuss designing an automated framework to replace manual wiring by injecting types, DOM elements, and events. The framework will be implemented using a test-driven approach. Finally, the simplified wiring code using the framework will be compared to the original manual wiring code.
Tellurium is a UI module based web testing framework. The UI module is a collection of UI elements you group together. Usually, the UI module represents a composite UI object in the format of nested basic UI elements. The UI module makes it possible to build UI elements' locators at run time. The framework does object to locator mapping (OLM) automatically at run time so that you can define UI objects simply by their attributes and write your selenium tests just like writing JUnit/TestNG tests. Since the framework constructs the actual locator automatically at run-time and it uses the Group Locating Concept (GLC) to exploit information inside a collection of UI components to help finding their locators, Tellurium is more robust, flexible, reusable compared with the Selenium testing framework.
This is a short version.
Tellurium is a UI module based web testing framework. The UI module is a collection of UI elements you group together. Usually, the UI module represents a composite UI object in the format of nested basic UI elements. The UI module makes it possible to build UI elements' locators at run time. The framework does object to locator mapping (OLM) automatically at run time so that you can define UI objects simply by their attributes and write your selenium tests just like writing JUnit/TestNG tests. Since the framework constructs the actual locator automatically at run-time and it uses the Group Locating Concept (GLC) to exploit information inside a collection of UI components to help finding their locators, Tellurium is more robust, flexible, reusable compared with the Selenium testing framework.
This is a short version.
Appium Mobile Testing: Nakov at BurgasConf - July 2021Svetlin Nakov
Automated testing of Android apps using Appium, AndroidDriver, Selenium and C#.
Speaker: Svetlin Nakov
BurgasConf, July 2021
Contents:
Appium: Overview, Architecture, Installation
The Android Emulator
Appium for Android App Automation
Inspecting Android apps UI from Appium
Using AndroidDriver<AndroidElement>
Using Appium for Android from NUnit
Testing on Physical Android Device
Continuous Integration and Code Coverage in XcodeHiep Luong
Xcode 7 includes new code coverage features to help you design a powerful test harness for your app. Learn all about coverage along with integration and improvements with Xcode Server.
https://developer.apple.com/videos/play/wwdc2015/410/
Introduction to html5 game programming with ImpactJsLuca Galli
A brief introduction to HTML5 Game Development that describes and use ImpactJs, one of the most famous and complete frameworks for HTML5 Games, mostly for learning purposes. The benefits of HTML5 Games are described, along with the importance of using a Framework and describing in details the ImpactJs Game Engine (no code provided, since it's proprietary). Two different games are coded on the fly during the lesson, while providing tips and suggestions. The Reference, Bibliography and Resources section provide useful pointers for beginners.
Lecture on Android unit testing and instrumentation testing, mDevCamp 2015.
Overview of available libraries and frameworks, and their capabilities and drawbacks.
Writing and Testing JavaScript-heavy Web 2.0 apps with JSUnitAlex Chaffee
With the advent of the so-called Web 2.0 platform, more and more applications are using client-side JavaScript for vital features. In fact, some applications are so JS-heavy that they redefine JavaScript as a full-fledged application development language. In this tutorial we discuss some architectural considerations of JS- and AJAX-heavy applications and present in detail our testing framework, with plenty of code examples.
Accelerate your Lotus Domino Web Applications with Dojo and XPagesDavalen LLC
Lotusphere Comes to You 2009: Richmond
Accelerate your Lotus Domino Web Applications with Dojo and XPages
Todd Weimer
Senior Consultant & Lotus Practice Manager – Davalen LLC
Presentation Outline:
What is Dojo?
Using the Dojo framework in your existing Lotus Domino Applications
Demo
Brief introduction to XPages
Using Dojo in XPages
Demo
Learn How to Unit Test Your Android Application (with Robolectric)Marakana Inc.
Robolectric is an open source Android unit testing framework that makes it possible to run unit tests against your Android application code outside of the emulator - in the IDE. Robolectric gives you the scaffolding to run your tests quickly so you can make fast iterations and refactor your code with confidence.
** Check out the video for this presentation at marakana.com: http://mrkn.co/f/192 **
This presentation was given at the San Francisco Android User Group on Oct. 26, 2010.
UNA PROPUESTA DE TRABAJO COLABORATIVO PARA EL ANÁLISIS REFLEXIVO DE LA PRÁCTI...ProfessorPrincipiante
Una característica que se advierte desde la formación inicial de los futuros
profesores de Biología, es la falta de competencias necesarias para el trabajo grupal.
Frente a esto y atendiendo a los objetivos de la asignatura de Práctica de la Enseñanza
del Profesorado en Ciencias Biológica, se realizó una propuesta de trabajo colaborativo.
La construcción del saber práctico se favorece al comprender y reflexionar con otros,
complementando diferentes miradas, resignificando la teoría y contribuyendo a superar
dificultades de los estudiantes frente al trabajo grupal. Considerando fundamental la
instancia de la formación docente inicial, es que se implementó una propuesta a través de
la cual, los alumnos elaboraron un proyecto didáctico, concebido como una hipótesis de
trabajo. Luego de llevar a cabo una práctica aislada sustentada en sus proyectos, se
solicitó que realizaran un análisis crítico del mismo.
Appium Mobile Testing: Nakov at BurgasConf - July 2021Svetlin Nakov
Automated testing of Android apps using Appium, AndroidDriver, Selenium and C#.
Speaker: Svetlin Nakov
BurgasConf, July 2021
Contents:
Appium: Overview, Architecture, Installation
The Android Emulator
Appium for Android App Automation
Inspecting Android apps UI from Appium
Using AndroidDriver<AndroidElement>
Using Appium for Android from NUnit
Testing on Physical Android Device
Continuous Integration and Code Coverage in XcodeHiep Luong
Xcode 7 includes new code coverage features to help you design a powerful test harness for your app. Learn all about coverage along with integration and improvements with Xcode Server.
https://developer.apple.com/videos/play/wwdc2015/410/
Introduction to html5 game programming with ImpactJsLuca Galli
A brief introduction to HTML5 Game Development that describes and use ImpactJs, one of the most famous and complete frameworks for HTML5 Games, mostly for learning purposes. The benefits of HTML5 Games are described, along with the importance of using a Framework and describing in details the ImpactJs Game Engine (no code provided, since it's proprietary). Two different games are coded on the fly during the lesson, while providing tips and suggestions. The Reference, Bibliography and Resources section provide useful pointers for beginners.
Lecture on Android unit testing and instrumentation testing, mDevCamp 2015.
Overview of available libraries and frameworks, and their capabilities and drawbacks.
Writing and Testing JavaScript-heavy Web 2.0 apps with JSUnitAlex Chaffee
With the advent of the so-called Web 2.0 platform, more and more applications are using client-side JavaScript for vital features. In fact, some applications are so JS-heavy that they redefine JavaScript as a full-fledged application development language. In this tutorial we discuss some architectural considerations of JS- and AJAX-heavy applications and present in detail our testing framework, with plenty of code examples.
Accelerate your Lotus Domino Web Applications with Dojo and XPagesDavalen LLC
Lotusphere Comes to You 2009: Richmond
Accelerate your Lotus Domino Web Applications with Dojo and XPages
Todd Weimer
Senior Consultant & Lotus Practice Manager – Davalen LLC
Presentation Outline:
What is Dojo?
Using the Dojo framework in your existing Lotus Domino Applications
Demo
Brief introduction to XPages
Using Dojo in XPages
Demo
Learn How to Unit Test Your Android Application (with Robolectric)Marakana Inc.
Robolectric is an open source Android unit testing framework that makes it possible to run unit tests against your Android application code outside of the emulator - in the IDE. Robolectric gives you the scaffolding to run your tests quickly so you can make fast iterations and refactor your code with confidence.
** Check out the video for this presentation at marakana.com: http://mrkn.co/f/192 **
This presentation was given at the San Francisco Android User Group on Oct. 26, 2010.
UNA PROPUESTA DE TRABAJO COLABORATIVO PARA EL ANÁLISIS REFLEXIVO DE LA PRÁCTI...ProfessorPrincipiante
Una característica que se advierte desde la formación inicial de los futuros
profesores de Biología, es la falta de competencias necesarias para el trabajo grupal.
Frente a esto y atendiendo a los objetivos de la asignatura de Práctica de la Enseñanza
del Profesorado en Ciencias Biológica, se realizó una propuesta de trabajo colaborativo.
La construcción del saber práctico se favorece al comprender y reflexionar con otros,
complementando diferentes miradas, resignificando la teoría y contribuyendo a superar
dificultades de los estudiantes frente al trabajo grupal. Considerando fundamental la
instancia de la formación docente inicial, es que se implementó una propuesta a través de
la cual, los alumnos elaboraron un proyecto didáctico, concebido como una hipótesis de
trabajo. Luego de llevar a cabo una práctica aislada sustentada en sus proyectos, se
solicitó que realizaran un análisis crítico del mismo.
With its large number of statues, Berlin honours man's talent and imagination.
'Berlin Statues' gives voice to Berlin's memory and its stories.
Apparently silent, these statues continue with the telling of their stories by establishing
a constant dialogue with the places within which they reside.
'Berlin Statues' is an emotive and narrative tour of locations away from the well-trodden tourist paths.
NCDevCon 2017 - Cross Platform Mobile AppsJohn M. Wargo
Building cross-platform mobile apps using open source tools. A manic paced session where I build the same app across 4 different open source mobile development frameworks.
Opendaylight is a project which promotes the Software Defined Networking.
Officially started on April -8th-2013.
The linux foundation planned an pivotal role in it, but it’s a consortium and multiple tech companies are partnered to led the SDN.
Its based on Eclipse Public License – v 1.0 (EPL).
------------------
Software defined networking is a research area which let a network to program, It also output network control applications, and those applications are to control the network
Example :
A network formed by the openflow enabled switch.
Controller Platform provides the OPEN APIs to program the network.
Controller Applications control the network based on the needs
In this talk John Zaccone will present tips and best practices for developing dockerized applications. We will start with the simple question: "Why Docker?", then dive into practical knowledge for developers to apply on their own. John will cover best practices concerning Dockerfiles and the best tools to use for developing. We will also talk about the "hand-off" between developer and operations and how the two roles can work together to address broad issues such as CI/CD and security. After John's talk, stay tuned for Scott Coulton's talk that will dive deeper into Docker for Ops.
DevOps on AWS: Deep Dive on Continuous Delivery and the AWS Developer ToolsAmazon Web Services
Today’s cutting-edge companies have software release cycles measured in days instead of months. This agility is enabled by the DevOps practice of continuous delivery, which automates building, testing, and deploying all code changes. This automation helps you catch bugs sooner and accelerates developer productivity. In this session, we’ll share the processes that Amazon’s engineers use to practice DevOps and discuss how you can bring these processes to your company by using a new set of AWS tools (AWS CodePipeline and AWS CodeDeploy). These services were inspired by Amazon's own internal developer tools and DevOps culture.
UiPath Test Automation using UiPath Test Suite series, part 6DianaGray10
Welcome to UiPath Test Automation using UiPath Test Suite series part 6. In this session, we will cover Test Automation with generative AI and Open AI.
UiPath Test Automation with generative AI and Open AI webinar offers an in-depth exploration of leveraging cutting-edge technologies for test automation within the UiPath platform. Attendees will delve into the integration of generative AI, a test automation solution, with Open AI advanced natural language processing capabilities.
Throughout the session, participants will discover how this synergy empowers testers to automate repetitive tasks, enhance testing accuracy, and expedite the software testing life cycle. Topics covered include the seamless integration process, practical use cases, and the benefits of harnessing AI-driven automation for UiPath testing initiatives. By attending this webinar, testers, and automation professionals can gain valuable insights into harnessing the power of AI to optimize their test automation workflows within the UiPath ecosystem, ultimately driving efficiency and quality in software development processes.
What will you get from this session?
1. Insights into integrating generative AI.
2. Understanding how this integration enhances test automation within the UiPath platform
3. Practical demonstrations
4. Exploration of real-world use cases illustrating the benefits of AI-driven test automation for UiPath
Topics covered:
What is generative AI
Test Automation with generative AI and Open AI.
UiPath integration with generative AI
Speaker:
Deepak Rai, Automation Practice Lead, Boundaryless Group and UiPath MVP
Epistemic Interaction - tuning interfaces to provide information for AI supportAlan Dix
Paper presented at SYNERGY workshop at AVI 2024, Genoa, Italy. 3rd June 2024
https://alandix.com/academic/papers/synergy2024-epistemic/
As machine learning integrates deeper into human-computer interactions, the concept of epistemic interaction emerges, aiming to refine these interactions to enhance system adaptability. This approach encourages minor, intentional adjustments in user behaviour to enrich the data available for system learning. This paper introduces epistemic interaction within the context of human-system communication, illustrating how deliberate interaction design can improve system understanding and adaptation. Through concrete examples, we demonstrate the potential of epistemic interaction to significantly advance human-computer interaction by leveraging intuitive human communication strategies to inform system design and functionality, offering a novel pathway for enriching user-system engagements.
Goodbye Windows 11: Make Way for Nitrux Linux 3.5.0!SOFTTECHHUB
As the digital landscape continually evolves, operating systems play a critical role in shaping user experiences and productivity. The launch of Nitrux Linux 3.5.0 marks a significant milestone, offering a robust alternative to traditional systems such as Windows 11. This article delves into the essence of Nitrux Linux 3.5.0, exploring its unique features, advantages, and how it stands as a compelling choice for both casual users and tech enthusiasts.
Removing Uninteresting Bytes in Software FuzzingAftab Hussain
Imagine a world where software fuzzing, the process of mutating bytes in test seeds to uncover hidden and erroneous program behaviors, becomes faster and more effective. A lot depends on the initial seeds, which can significantly dictate the trajectory of a fuzzing campaign, particularly in terms of how long it takes to uncover interesting behaviour in your code. We introduce DIAR, a technique designed to speedup fuzzing campaigns by pinpointing and eliminating those uninteresting bytes in the seeds. Picture this: instead of wasting valuable resources on meaningless mutations in large, bloated seeds, DIAR removes the unnecessary bytes, streamlining the entire process.
In this work, we equipped AFL, a popular fuzzer, with DIAR and examined two critical Linux libraries -- Libxml's xmllint, a tool for parsing xml documents, and Binutil's readelf, an essential debugging and security analysis command-line tool used to display detailed information about ELF (Executable and Linkable Format). Our preliminary results show that AFL+DIAR does not only discover new paths more quickly but also achieves higher coverage overall. This work thus showcases how starting with lean and optimized seeds can lead to faster, more comprehensive fuzzing campaigns -- and DIAR helps you find such seeds.
- These are slides of the talk given at IEEE International Conference on Software Testing Verification and Validation Workshop, ICSTW 2022.
Climate Impact of Software Testing at Nordic Testing DaysKari Kakkonen
My slides at Nordic Testing Days 6.6.2024
Climate impact / sustainability of software testing discussed on the talk. ICT and testing must carry their part of global responsibility to help with the climat warming. We can minimize the carbon footprint but we can also have a carbon handprint, a positive impact on the climate. Quality characteristics can be added with sustainability, and then measured continuously. Test environments can be used less, and in smaller scale and on demand. Test techniques can be used in optimizing or minimizing number of tests. Test automation can be used to speed up testing.
Why You Should Replace Windows 11 with Nitrux Linux 3.5.0 for enhanced perfor...SOFTTECHHUB
The choice of an operating system plays a pivotal role in shaping our computing experience. For decades, Microsoft's Windows has dominated the market, offering a familiar and widely adopted platform for personal and professional use. However, as technological advancements continue to push the boundaries of innovation, alternative operating systems have emerged, challenging the status quo and offering users a fresh perspective on computing.
One such alternative that has garnered significant attention and acclaim is Nitrux Linux 3.5.0, a sleek, powerful, and user-friendly Linux distribution that promises to redefine the way we interact with our devices. With its focus on performance, security, and customization, Nitrux Linux presents a compelling case for those seeking to break free from the constraints of proprietary software and embrace the freedom and flexibility of open-source computing.
Dr. Sean Tan, Head of Data Science, Changi Airport Group
Discover how Changi Airport Group (CAG) leverages graph technologies and generative AI to revolutionize their search capabilities. This session delves into the unique search needs of CAG’s diverse passengers and customers, showcasing how graph data structures enhance the accuracy and relevance of AI-generated search results, mitigating the risk of “hallucinations” and improving the overall customer journey.
Sudheer Mechineni, Head of Application Frameworks, Standard Chartered Bank
Discover how Standard Chartered Bank harnessed the power of Neo4j to transform complex data access challenges into a dynamic, scalable graph database solution. This keynote will cover their journey from initial adoption to deploying a fully automated, enterprise-grade causal cluster, highlighting key strategies for modelling organisational changes and ensuring robust disaster recovery. Learn how these innovations have not only enhanced Standard Chartered Bank’s data infrastructure but also positioned them as pioneers in the banking sector’s adoption of graph technology.
zkStudyClub - Reef: Fast Succinct Non-Interactive Zero-Knowledge Regex ProofsAlex Pruden
This paper presents Reef, a system for generating publicly verifiable succinct non-interactive zero-knowledge proofs that a committed document matches or does not match a regular expression. We describe applications such as proving the strength of passwords, the provenance of email despite redactions, the validity of oblivious DNS queries, and the existence of mutations in DNA. Reef supports the Perl Compatible Regular Expression syntax, including wildcards, alternation, ranges, capture groups, Kleene star, negations, and lookarounds. Reef introduces a new type of automata, Skipping Alternating Finite Automata (SAFA), that skips irrelevant parts of a document when producing proofs without undermining soundness, and instantiates SAFA with a lookup argument. Our experimental evaluation confirms that Reef can generate proofs for documents with 32M characters; the proofs are small and cheap to verify (under a second).
Paper: https://eprint.iacr.org/2023/1886
Securing your Kubernetes cluster_ a step-by-step guide to success !KatiaHIMEUR1
Today, after several years of existence, an extremely active community and an ultra-dynamic ecosystem, Kubernetes has established itself as the de facto standard in container orchestration. Thanks to a wide range of managed services, it has never been so easy to set up a ready-to-use Kubernetes cluster.
However, this ease of use means that the subject of security in Kubernetes is often left for later, or even neglected. This exposes companies to significant risks.
In this talk, I'll show you step-by-step how to secure your Kubernetes cluster for greater peace of mind and reliability.
A tale of scale & speed: How the US Navy is enabling software delivery from l...sonjaschweigert1
Rapid and secure feature delivery is a goal across every application team and every branch of the DoD. The Navy’s DevSecOps platform, Party Barge, has achieved:
- Reduction in onboarding time from 5 weeks to 1 day
- Improved developer experience and productivity through actionable findings and reduction of false positives
- Maintenance of superior security standards and inherent policy enforcement with Authorization to Operate (ATO)
Development teams can ship efficiently and ensure applications are cyber ready for Navy Authorizing Officials (AOs). In this webinar, Sigma Defense and Anchore will give attendees a look behind the scenes and demo secure pipeline automation and security artifacts that speed up application ATO and time to production.
We will cover:
- How to remove silos in DevSecOps
- How to build efficient development pipeline roles and component templates
- How to deliver security artifacts that matter for ATO’s (SBOMs, vulnerability reports, and policy evidence)
- How to streamline operations with automated policy checks on container images
The Art of the Pitch: WordPress Relationships and SalesLaura Byrne
Clients don’t know what they don’t know. What web solutions are right for them? How does WordPress come into the picture? How do you make sure you understand scope and timeline? What do you do if sometime changes?
All these questions and more will be explored as we talk about matching clients’ needs with what your agency offers without pulling teeth or pulling your hair out. Practical tips, and strategies for successful relationship building that leads to closing the deal.
Communications Mining Series - Zero to Hero - Session 1DianaGray10
This session provides introduction to UiPath Communication Mining, importance and platform overview. You will acquire a good understand of the phases in Communication Mining as we go over the platform with you. Topics covered:
• Communication Mining Overview
• Why is it important?
• How can it help today’s business and the benefits
• Phases in Communication Mining
• Demo on Platform overview
• Q/A
Communications Mining Series - Zero to Hero - Session 1
tut0000021-hevery
1. Table of Contents
Table of Contents........................................................................................................................................ i
Instructors Biographies.............................................................................................................................. ii
Agenda...................................................................................................................................................... iii
Objectives Of the Course.......................................................................................................................... iv
1Setting Up Environment...........................................................................................................................6
1.1Setting up Mercurial.........................................................................................................................6
1.2Setting up Your Favorite Text Editor or Eclipse...............................................................................6
1.3Getting the Source............................................................................................................................ 6
1.4Setting up Test Runner..................................................................................................................... 8
2Understanding Manual Dependency Injection.......................................................................................10
2.1Application wiring diagram............................................................................................................10
2.2Understanding the Need for DI...................................................................................................... 10
3Designing Automated Dependency Injection Framework..................................................................... 12
3.1Replacing the Lost Information Of Declared Types.......................................................................12
3.2Ability to Inject Types.................................................................................................................... 12
3.3Ability to Inject DOM Elements.................................................................................................... 14
3.4Ability to Inject Events...................................................................................................................14
4Implementing the Framework................................................................................................................ 16
5Comparing the Resulting Wiring Code.................................................................................................. 18
OOPSLA 2009 Tutorial i Miško Hevery
2. Instructors Biographies
Miško Hevery
misko@hevery.com
Google, Inc.
… works as an Agile Coach at Google where he is responsible for coaching Googlers to maintain the
high level of automated testing culture. This allows Google to do frequent releases of its web
applications with consistent high quality. Previously he worked at Adobe, Sun Microsystems, Intel, and
Xerox (to name a few), where he became an expert in building web applications in web related
technologies such as Java, JavaScript, Flex and ActionScript. He is very involved in Open Source
community and an author of several open source projects. Recently his interest in Test-Driven-
Development turned into Testability Explorer (http://code.google.com/p/testability-explorer) and
JsTestDriver (http://code.google.com/p/js-test-driver) with which he hopes to change the testing culture
of the open source community.
OOPSLA 2009 Tutorial ii Miško Hevery
3. Agenda
1. Setting up your environment
1. Setting up Mercurial
2. Setting up your favorite text editor or Eclipse
3. Setting up JsTestRunner
2. Getting the source
1. Checking out the source code
2. Running the code
3. Understanding manual Dependency Injection
1. Application wiring diagram
2. Understanding the need for DI
4. Designing automated Dependency Injection framework
1. Replacing the lost information of declared types
2. Injecting types
3. Injecting DOM elements
4. Injecting events
5. Implementing the framework
6. Cleaning up the bootstrap wiring code
7. Discussion of before and after code
OOPSLA 2009 Tutorial iii Miško Hevery
4. Objectives of the Course
Dependency Injection is a good practice even in dynamic languages. Because many dynamic languages
do not have type declarations, building an automatic DI framework presents its own set of challenges.
Furthermore, many concepts, such as scopes that are often associated with threads, change their
meaning in most dynamic languages which are single threaded. In this tutorial, we will build a simple
automatic DI framework and solve many of the challenges which are associated with lack of declared
types in such languages.
• Understand the need for Dependency Injection
◦ Dynamic languages are not special and still need Dependency Injection
• How to replace the lack of typing information in dynamic languages
• Injection is not limited to injecting object instances
◦ Building our own domain specific language
◦ The obvious: Injecting types
◦ Thinking outside the box: Injecting DOM elements, and events
• Dependency Injection simplifies the wiring of the application logic
◦ Comparing application bootstrap process before and after
OOPSLA 2009 Tutorial iv Miško Hevery
5. 1 Setting Up Environment
Before the tutorial we recommend that you complete all of the following steps:
1.1 Setting up Mercurial
The code for this project is located at:
• http://bitbucket.org/misko/misko-hevery-oopsla-09
You will need to install Mercurial for your platform:
• Home: http://mercurial.selenic.com/wiki/
• Download: http://mercurial.selenic.com/wiki/Download?
action=show&redirect=BinaryPackages
1.2 Getting the Source
After installing a copy of Mercurial you can download the source using the following command:
$ hg clone https://misko@bitbucket.org/misko/misko-hevery-oopsla-09/
1.3 Setting up Your Favorite Text Editor or Eclipse
You will need you favorite Text Editor for editing JavaScript, HTML, and CSS. We recommend Eclipse
which you can download and install from the link bellow. We have already set up an Eclipse workspace
for you in the Mercurial repository.
• Download Eclipse: http://www.eclipse.org/downloads/
• Install JavaScript Editor: From Eclipse
◦ Help → Install New Software
◦ Select: Work With: Galileo
◦ Select: Web, XML, and Java EE Development
◦ Complete the installation by clicking the “Next” button
• Install JsTestDriver for Eclipse
◦ Help → Install New Software
◦ Select: Work With: and enter: http://js-test-driver.googlecode.com/svn/update/
◦ Select JsTestDriver
◦ Complete the installation by clicking the “Next” button
• Import the DI project which you downloaded with Mercurial.
OOPSLA 2009 Tutorial Miško Hevery
6. 1.4 Setting up Test Runner
NOTE: All commands need to be executed from the root of the source code which you downloaded
with Mercurial.
The project comes with JavaScript tests which can be run from the command line as follows:
$ java -jar JsTestDriver.jar --port 4224
This will start a server on http://localhost:4224
Open your favorite browser (we don't recommend IE as it is slow) at http://localhost:4224 and click the
“Capture This Browser” link.
From a new command line enter:
$ java -jar JsTestDriver.jar --tests all
You should see something like this:
$ java -jar JsTestDriver.jar --tests all
........
Total 8 tests (Passed: 8; Fails: 0; Errors: 0) (10.00 ms)
Chrome 4.0.202.0 MacIntel: Run 8 tests (Passed: 8; Fails: 0; Errors
0) (10.00 ms)
OOPSLA 2009 Tutorial 2 Miško Hevery
7. 2 Understanding Manual Dependency Injection
2.1 Application Wiring Diagram
The application is a simple game of Tic-Tac-Toe as shown on the
right. The application is intentionally kept small for simplicity and
consists of these components.
• HTML (tic-tac-toe.html)
◦ #status: location of the status element.
◦ #board: location of the board game.
◦ #newGame: button reseting the game.
• Classes
◦ Board: Responsible for updating the DOM to show
current state of the board.
◦ State: Internal representation of the board, which can
determine a winner and reflects the DOM view of the
board.
◦ Status: Updates the status DOM with the player turn
and shows the winner.
◦ ManualDI: Bootstrap class which is responsible for wiring the application class together.
• Events
◦ Board Click: fired when the user clicks on the board game.
◦ New Game Click: fired when the user clicks on the “New Game Button.”
2.2 Understanding the Need for DI
A common misconception is that dynamic languages do not need Dependency Injection. The argument
is that in dynamic languages one can easily change the method definition at run time. Therefore no
method is untestable because all methods have seams where the normal flow of code execution can be
diverted for the purpose of test isolation through monkey-patching. While DI is very useful for testing,
it also aids the understanding of the code base. This benefit would be lost without DI. However, the
main fallacy of this argument stems from the fact that code is global constant, and monkey-patching the
code turns the global constants to mutable global state. While global constants don't present testability,
maintainability, or understandability problems, mutable global state presents problems in all previously
stated categories. It is true that while in static languages, such as Java, lack of DI spells death to
testability, lack of DI in dynamic languages still allows testability through monkey-patching. However,
it is not a best practice, and creates a problem of global state as stated above.
OOPSLA 2009 Tutorial 4 Miško Hevery
8. 3 Designing Automated Dependency Injection Framework
The file src/ManualDI.js contains all of the wiring of the application. This is an error prone
process as it can lead to mistakes which are hard to detect because there are no automated tests.
The goal is to completely replace this file with automatic DI. To achieve automatic DI we need to solve
several issues as discussed in more detail next.
3.1 Replacing the Lost Information of Declared Types
The automatic Dependency Injection works by looking at a constructor of a class to determine the
parameter types, then recursively looking at those types. Dynamic Languages usually don't contain this
information and therefore we need a mechanism for declaring the missing information. To solve this
problem, we will declare a class constant containing the missing meta-data information for the
framework.
See scr/Board.js and notice the class constant inject
Board = function (board, state) {
this.board = board;
this.nextPiece = "X";
this.state = state;
};
Board.inject = {
constructor:["#board", ":Status"],
scope: "singleton",
listen:[
{source:"#newGame", event:”click”, call:'reset'},
{source:"#board.box", event:”click”,
call:'addPiece', args:["@row", "@col"]}
]
};
The inject meta-data contains information used to automatically construct the object graph. Notice
that the references are prefixed with special characters:
• “:” inject an object of a given type
• “#” inject a DOM element with a given id (this is a jQuery selector)
• “@” inject a property of a given object
3.2 Injecting Types
The most important ability for any Dependency Injection framework is to instantiate and inject
instances of a given type. We will use the following syntax to locate objects.
var injector = new Injector();
var board = injector.getInstance(“:State”);
The goal of this tutorial is to implement an Injector class which can read the meta-data information of
classes and use it to instantiate the objects.
OOPSLA 2009 Tutorial 6 Miško Hevery
9. 3.3 Injecting DOM Elements
In addition to injecting types, common in most static language DI frameworks, we would also like the
ability to inject DOM elements, a common need in JavaScript code, using the jQuery selector syntax.
Therefore, asking for #board is equivalent to jQuery(document).find(“#board”).
3.4 Injecting Events
DOM element listeners are also common in JavaScript, and therefore, the ability to inject listeners is
desired. Our meta-data contains the “listen” directive which specifies in declarative way the kind of
events the class should listen on.
OOPSLA 2009 Tutorial 8 Miško Hevery
10. 4 Implementing the Framework
The goal of the tutorial is to implement an automatic DI framework which can read the meta-data and
use it to instantiate our application. We want to change the current ManualDI.js class from:
Main.prototype.bind = function() {
var boardElement = this.doc.find("#board");
var state = new State();
var board = new Board(boardElement, state);
var status = new Status(this.doc.find("#status"), state, function(){
return board.nextPiece;
});
boardElement.find('.box').click(function(){
var e = $(this);
board.addPiece(e.attr('row'), e.attr('col'));
status.update();
});
this.doc.find('#newGame').click(function(){
board.reset();
status.update();
});
board.reset();
};
to an automatic wiring DI as shown below:
Main.prototype.bind = function() {
var injector = new Injector();
var board = injector.getInstance(“:Board”);
board.reset();
};
The implementation will be done in the following way:
• All code will be test driven with unit tests and test first design
• First, we will implement the ability to instantiate pure objects such as State.js which will
allow us to replace new State() with injector.getInstance(“:State”)
• Then, we will add the ability to inject jQuery selectors which will allow us to replace the
complex instantiation of State with injector.getInstance(“:Status”)
• Finally, we will add the ability to inject listeners which will allow us to replace the whole
manual DI with injector.getInstance(“:Board”) which is the root object.
OOPSLA 2009 Tutorial 10 Miško Hevery
11. 5 Comparing the Resulting Wiring Code
When done with implementing the framework, we will discuss:
• The benefits of simplified code
• The different paths each of us took in the implementation
• The advantages and disadvantages of each of the implementations
• How we could further improve and grow the framework
OOPSLA 2009 Tutorial 12 Miško Hevery