The document describes a code kata exercise to develop a StringCalculator application using test-driven development. It provides requirements for the add() method of the StringCalculator class and outlines composing tests to verify each requirement fails initially and then developing the code to pass all tests. The requirements include handling empty strings, delimiters, optional delimiters, negative numbers, and ignoring large numbers. The process of writing tests before code and verifying all tests pass is demonstrated.
A code kata in C# to help practice techniques for safely removing dependencies form legacy code and creating unit tests. Questions? Suggestions? Contact @dubmun.
Having trouble wrapping you mind around unit testing in legacy code? Practice this kata and you'll have a good understanding of some basics. Break dependencies, inject stubs, write meaningful tests. Refactor with confidence. Version 2 is a complete overhaul to make the kata more readable and usable.
A code kata in C# to help practice techniques for safely removing dependencies form legacy code and creating unit tests. Questions? Suggestions? Contact @dubmun.
Having trouble wrapping you mind around unit testing in legacy code? Practice this kata and you'll have a good understanding of some basics. Break dependencies, inject stubs, write meaningful tests. Refactor with confidence. Version 2 is a complete overhaul to make the kata more readable and usable.
Implementing code-based load tests in JavaScript with the k6 performance testing tool.
Svetlin Nakov @ QA Challenge Accepted 2021
Load and performance testing aims to determine whether software meets speed, scalability and stability requirements under expected workloads. Old school performance testing tools like Apache JMeter are complex and heavy and are not well aligned with the modern QA automation and continuous integration trends.
In this talk Svetlin presents and demonstrates the "k6 framework" - a modern open-source load testing tool, which describes the load tests as JavaScript code. The k6 tool is very powerful, high-performance and developer-friendly. It allows load testing of Web apps and APIs, accessed through the HTTP protocol.
Svetlin also demonstrates how to install and use k6, how to run its test recorder, how to edit the recorded scripts at the k6 cloud and how to write k6 scripts in JavaScript (execute HTTP requests, write checks, define thresholds), and execute the scripts with certain number of virtual users for certain duration.
Hyper-pragmatic Pure FP testing with distage-testkit7mind
Having a proper test suite can turn ongoing application maintenance and development into pure joy – the best tests check meaningful properties, not the implementation details, and hold no impliict assumptions about their test environment - every test case must be self-contained and portable. To ensure that tests are free of implementation details and environment dependency, we may simply run them in a different test environment, with different implementations of components. But the boileplate and manual work involved in rewiring components, writing hardcoded fixtures and setting up different test environments make this very hard to do at scale. To tackle this problem we've created distage & distage-testkit, distage-testkit gives you the following superpowers:
* ability to easily swap out individual components or entire test environments
* principled & leak-free control of global resources for integration testing – docker containers, DBs, DDLs
* execute effects or allocate resources per-test, e.g. generate random fixtures per-test
* first-class testing of functional effects
* write tests as lambdas – access test fixtures via parameters or ZIO Environment
...and more! We'll also discuss general testing practices and what really distinguishes good tests from great tests.
Many Scala developers nowadays consider using Dependency Injection frameworks an anti-pattern incompatible with modern FP settings. We argue that it's just a consequence of a bad experience with legacy Java runtime reflection-based implementations that lack features important for modern functional programming, such as a first-class support for higher-kinded types. We argue that as a paradigm for structuring purely functional programs, DI with automatic wiring compares favorably against implicits, monad transformers, free monads, algebraic effects, cake pattern et al, enabling scaling and a degree of modularity unachievable by any manual wiring approach. This talk covers DIStage – a transparent, flexible and efficient DI framework for Scala that enables late binding, testability, effect separation and modular resource management at scale, working with, instead of compromising the Scala type system.
Documentation: https://izumi.7mind.io/latest/release/doc/distage/
Presentation made by Josep Vall-llovera, CTO @Clapps, for the Barcelona Salesforce Developer Group.
Most of the information of these slides have been extracted from Salesforce.com official webpage and they have been used to explain what is Lightning and what you can do with it (as an Admin and/or Dev). I highly recommend to take a look at the repo, where you will find a Lightning application for the Barcelona SDG developed by me.
Checkout github repo: https://github.com/Valnavjo/sdgbarcelona.git
Frameworks are bulky, quirky, and non-compositional, which has led to a rejection of Spring and similar frameworks in the Scala ecosystem. Yet, despite their drawbacks, frameworks have been used to boost team productivity in many large companies. In this presentation, Pavel and Kai will introduce Izumi 1.0, a Scala microframework based on compositional functional programming. Designed to help you and your team achieve new levels of productivity, Izumi now includes full compile-time checks for your configurable applications and completely reworked Tagless Final hierarchy for Bifunctors and Trifunctors.
Most of the companies starting using JIRA for Project Management. Requirements, Bugs and Development Tasks are already being tracked through it. Its time to use it for Test Cases also. This will improve transparency.
Scala, Functional Programming and Team Productivity7mind
Many engineers spend a lot of time doing repetitive things. In this talk we examine typical productivity issues, which observed in many different companies, and show how to deal with them. We cover:
* Microservices and Monoliths,
* Introspection and Debugging,
* Logging,
* Modular Design,
* Functional Programming,
* RPC and REST,
* Tests and Delivery Pipeline.
This talk is a retrospective of our actions that helped our customer to cut development costs by 50%. We expect our experience to be applicable to most small and medium-sized teams and companies using Scala.
A presentation made for the AngularJS-IL meetup group that took place in May 2014 at Google TLV Campus. its a demonstration of Unit testing an AngularJS component with jasmine and karma.
Implementing code-based load tests in JavaScript with the k6 performance testing tool.
Svetlin Nakov @ QA Challenge Accepted 2021
Load and performance testing aims to determine whether software meets speed, scalability and stability requirements under expected workloads. Old school performance testing tools like Apache JMeter are complex and heavy and are not well aligned with the modern QA automation and continuous integration trends.
In this talk Svetlin presents and demonstrates the "k6 framework" - a modern open-source load testing tool, which describes the load tests as JavaScript code. The k6 tool is very powerful, high-performance and developer-friendly. It allows load testing of Web apps and APIs, accessed through the HTTP protocol.
Svetlin also demonstrates how to install and use k6, how to run its test recorder, how to edit the recorded scripts at the k6 cloud and how to write k6 scripts in JavaScript (execute HTTP requests, write checks, define thresholds), and execute the scripts with certain number of virtual users for certain duration.
Hyper-pragmatic Pure FP testing with distage-testkit7mind
Having a proper test suite can turn ongoing application maintenance and development into pure joy – the best tests check meaningful properties, not the implementation details, and hold no impliict assumptions about their test environment - every test case must be self-contained and portable. To ensure that tests are free of implementation details and environment dependency, we may simply run them in a different test environment, with different implementations of components. But the boileplate and manual work involved in rewiring components, writing hardcoded fixtures and setting up different test environments make this very hard to do at scale. To tackle this problem we've created distage & distage-testkit, distage-testkit gives you the following superpowers:
* ability to easily swap out individual components or entire test environments
* principled & leak-free control of global resources for integration testing – docker containers, DBs, DDLs
* execute effects or allocate resources per-test, e.g. generate random fixtures per-test
* first-class testing of functional effects
* write tests as lambdas – access test fixtures via parameters or ZIO Environment
...and more! We'll also discuss general testing practices and what really distinguishes good tests from great tests.
Many Scala developers nowadays consider using Dependency Injection frameworks an anti-pattern incompatible with modern FP settings. We argue that it's just a consequence of a bad experience with legacy Java runtime reflection-based implementations that lack features important for modern functional programming, such as a first-class support for higher-kinded types. We argue that as a paradigm for structuring purely functional programs, DI with automatic wiring compares favorably against implicits, monad transformers, free monads, algebraic effects, cake pattern et al, enabling scaling and a degree of modularity unachievable by any manual wiring approach. This talk covers DIStage – a transparent, flexible and efficient DI framework for Scala that enables late binding, testability, effect separation and modular resource management at scale, working with, instead of compromising the Scala type system.
Documentation: https://izumi.7mind.io/latest/release/doc/distage/
Presentation made by Josep Vall-llovera, CTO @Clapps, for the Barcelona Salesforce Developer Group.
Most of the information of these slides have been extracted from Salesforce.com official webpage and they have been used to explain what is Lightning and what you can do with it (as an Admin and/or Dev). I highly recommend to take a look at the repo, where you will find a Lightning application for the Barcelona SDG developed by me.
Checkout github repo: https://github.com/Valnavjo/sdgbarcelona.git
Frameworks are bulky, quirky, and non-compositional, which has led to a rejection of Spring and similar frameworks in the Scala ecosystem. Yet, despite their drawbacks, frameworks have been used to boost team productivity in many large companies. In this presentation, Pavel and Kai will introduce Izumi 1.0, a Scala microframework based on compositional functional programming. Designed to help you and your team achieve new levels of productivity, Izumi now includes full compile-time checks for your configurable applications and completely reworked Tagless Final hierarchy for Bifunctors and Trifunctors.
Most of the companies starting using JIRA for Project Management. Requirements, Bugs and Development Tasks are already being tracked through it. Its time to use it for Test Cases also. This will improve transparency.
Scala, Functional Programming and Team Productivity7mind
Many engineers spend a lot of time doing repetitive things. In this talk we examine typical productivity issues, which observed in many different companies, and show how to deal with them. We cover:
* Microservices and Monoliths,
* Introspection and Debugging,
* Logging,
* Modular Design,
* Functional Programming,
* RPC and REST,
* Tests and Delivery Pipeline.
This talk is a retrospective of our actions that helped our customer to cut development costs by 50%. We expect our experience to be applicable to most small and medium-sized teams and companies using Scala.
A presentation made for the AngularJS-IL meetup group that took place in May 2014 at Google TLV Campus. its a demonstration of Unit testing an AngularJS component with jasmine and karma.
An overview of the Android marketshare gives context to why Android security is so important. We look at some of the primary reasons Android is insecure and a couple of solutions that have been proposed.
2. Ground Rules
● do not skip ahead
● no man left behind
● we will only get as far as the whole group gets by 12:50 to
allow for discussion at the end
● when we're out of time, that's it
● next time, start from beginning again, not where we left off
● if participating, commit and obey the rules
● if observing, please do not assist or distract
4. Compose Test
there should be a StringCalculator
● Launch FlashBuilder
● Create an application to run unit tests
● Create a new Flex Desktop Project called
StringCalculatorTestRunner in your kata directory
● Add the FlexUnit swc's to to libs
● Add a class named Suite to a package named 'suite'
● Add a class named Test to a package named 'test'
5. Compose Test
there should be a StringCalculator
● add flexui:TestRunnerBase component to the test application
● add creationComplete handler to instantiate, init & run FlexUnitCore
<s:WindowedApplication xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark"
xmlns:mx="library://ns.adobe.com/flex/mx"
xmlns:flexui="org.flexunit.flexui.*"
width="1200" height="900"
creationComplete="application1_creationCompleteHandler(event)">
<fx:Script>
<![CDATA[
import mx.events.FlexEvent;
import org.flexunit.runner.FlexUnitCore;
import suite.Suite;
protected function application1_creationCompleteHandler(event:FlexEvent):void{
var core:FlexUnitCore = new FlexUnitCore();
core.addListener(myRunnerBase);
core.run(suite.Suite);
}
]]>
</fx:Script>
<flexui:TestRunnerBase id="myRunnerBase" />
</s:WindowedApplication>
6. Compose Test
there should be a StringCalculator
● Edit the Suite class
package suite{
import tests.Test;
[Suite]
[RunWith("org.flexunit.runners.Suite")]
public class Suite{
public var test:Test;
}
}
7. Compose Test
there should be a StringCalculator
● Edit the Test class: add a passing test to get started
package tests{
import org.flexunit.Assert;
public class Test{
[Test]
public function Run_App_CompilesWithoutError():void{
var expected:Number = 3;
var actual:Number = Math.round(3.4999999);
Assert.assertEquals(expected, actual);
}
}
}
8. Develop
there should be a StringCalculator
● Create a directory on your computer for this kata project:
kata/StringCalculator
● Create a new ActionScript web project called
StringCalculator in your directory with default settings
● In Test App's Project Properties>Build Path>Source Path,
add your StringCalculator project's src directory
● Run the test app, resolve any compiler issues
● See starter test pass
10. Compose Test
add() should exist and return 0 for empty string
● add a test called 'Add_InputEmptyString_ReturnsZero'
● instantiate the StringCalculator class
● call StringCalculator.add()
● Command+1 to 'create method add'
● run StringCalculatorTestRunner
● see test fail
11. Develop
add() should exist and return 0 for empty string
● add a String parameter: add(numbers:String)
● add a return type of Number: add():Number
● add statements: var sum:Number; return sum;
12. Compose Test
add() should exist and return 0 for empty string
● assert that 0 is returned for an empty string
● run StringCalclatorTestRunner
● see test fail
13. Develop
add() should exist and return 0 for empty string
● add a condition where empty string returns 0
● run StringCalclatorTestRunner
● see test pass
Congratulations!
Your first requirement is formally specified
Your application's intent is formally documented
Your application works as expected
14. Review Requirement
The calculator's add function should:
● throw exception for more than 2 inputs
● return the value of 1 valid input
● return the sum of 2 valid inputs
15. Compose Test
throw exception for more than 2 inputs
● move StringCalculator to class and create in [Before]
● add test called
'Add_InputMoreThanTwoValues_ThrowsError'
● compose the test and it's assertion
● run StringCalclatorTestRunner
● see test fail
16. Develop
throw exception for more than 2 inputs
● add a condition where too many inputs throws an error
● run StringCalclatorTestRunner
● see all tests pass
17. Compose Test
return the value of 1 valid input
● add test called 'Add_InputSingleValue_ReturnsInputValue'
● compose the test and it's assertion
● run StringCalclatorTestRunner
● see test fail
18. Develop
return the value of 1 valid input
● add condition where single input value is returned
● run StringCalclatorTestRunner
● see all tests pass
19. Compose Test
return the sum of 2 valid inputs
● add test called 'Add_InputTwoValues_ReturnsSum'
● compose the test and it's assertion
● run StringCalclatorTestRunner
● see test fail
20. Develop
return the sum of 2 valid inputs
● add condition where sum of two inputs is returned
● run StringCalclatorTestRunner
● see all tests pass
21. Review Requirement
The calculator's add function should return the sum of any
number of inputs
Here is a great example of how requirements change on us
UnitTests help us to refactor code, safely and with confidence
22. Compose Test
return the sum of any number of inputs
● [Ignore] 'Add_InputMoreThanTwoValues_ThrowsError'
● add test called
'Add_InputMoreThanTwoValues_ReturnsSum'
● compose the test and it's assertion
● run StringCalclatorTestRunner
● see test fail
23. Develop
return the sum of any number of inputs
● remove condition where more than two inputs throws an
error
● add condition and logic to add any number of inputs
● run StringCalclatorTestRunner
● see all tests pass
24. Review Requirement
The calculator's add function should:
● accept the new line character 'n' as a delimeter
● 'n' and ',' are allowed in the same input: add('1n2,3')
25. Compose Test
accept the new line character 'n' as a delimiter
● add test called
'Add_InputsDelimetedByNewLine_ReturnsSum'
● compose test and it's assertion
● run StringCalculatorTestRunner
● see test fail
26. Develop
accept the new line character 'n' as a delimiter
● solve for requirement (eg. replace 'n' with ',')
● run StringCalculatorTestRunner
● see all tests pass
27. Review Requirement
The calculator's add function should:
● optionally allow for different default delimiters via "//dn"
● example: add("//;n3;5;2n10;1) should return 21
28. Compose Test
optionally allow for different default delimiters via "//dn"
● add test called 'Add_InputOptionalDelimiter_ReturnSum'
● compose test and it's assertion
● run StringCalculatorTestRunner
● see test fail
29. Develop
optionally allow for different default delimiters via "//dn"
● solve for requirement
● run StringCalculatorTestRunner
● see all tests pass
30. Review Requirement
The calculator's add function should:
● throw an exception when passed a negative number
● exception message is "negatives not allowed"
● include negative in message
● if multiple negatives, include them all in message
31. Compose Test
throw an exception when passed negative number(s)
● add test called
'Add_InputNegativeNumbers_ThrowsException'
● compose test and it's assertion
● run StringCalculatorTestRunner
● see test fail
32. Develop
throw an exception when passed negative number(s)
● solve for requirement
● run StringCalculatorTestRunner
● see all tests pass
34. Compose Test
ignore numbers larger than 1000
● add test called
'Add_InputValuesLargerThan1000_ReturnsSumIgnoringLargeNumbers'
● compose test and it's assertion
● run StringCalculatorTestRunner
● see test fail
35. Develop
ignore numbers larger than 1000
● solve for requirement
● run StringCalculatorTestRunner
● see all tests pass