Unit tests can do more than just prevent regressions. Written properly, they can also serve as documentation of the code - documentation which can be executed to verify that it is true.
Test-driven development for TYPO3 (T3DD11)Oliver Klee
This document discusses test-driven development for TYPO3. It provides an overview of unit testing, describing how automated testing is faster and more reliable than manual testing. It also summarizes a real estate manager extension that contains over 1600 tests that run in under 60 seconds. The document then discusses key testing concepts and terminology like test cases, test suites, assertions, and the lifecycle of unit tests. It promotes a test-first development approach and describes how to write meaningful, well-named unit tests. Finally, it outlines how the TYPO3 testing framework can fake or simulate different parts of an application to enable isolated and repeatable testing.
The Impact of Test Case Summaries on Bug Fixing Performance: An Empirical Inv...Sebastiano Panichella
Automated test generation tools have been widely investigated
with the goal of reducing the cost of testing activities.
However, generated tests have been shown not to help developers in detecting and finding more bugs even though
they reach higher structural coverage compared to manual
testing. The main reason is that generated tests are di-
cult to understand and maintain. Our paper proposes an
approach, coined TestDescriber, which automatically generates
test case summaries of the portion of code exercised by
each individual test, thereby improving understandability.
We argue that this approach can complement the current
techniques around automated unit test generation or search based techniques designed to generate a possibly minimal set
of test cases. In evaluating our approach we found that (1)
developers find twice as many bugs, and (2) test case summaries
significantly improve the comprehensibility of test
cases, which is considered particularly useful by developers.
This document provides an introduction to using the Google Test framework for unit testing C++ code. It begins with an example of a simple test for a function called calc_isect. It then demonstrates how to add assertions to tests, use test fixtures to reduce duplicated setup code, and generate parameterized tests. The document also covers best practices for test organization, installing and using Google Test, and some key features like XML output and selecting subsets of tests. Overall, the document serves as a tutorial for getting started with the Google Test framework for writing and running unit tests in C++ projects.
The document summarizes the key differences between JUnit 4 and JUnit 5 (alpha). Some of the main changes in JUnit 5 include updated annotations like @Test, support for lambda-based assertions using Hamcrest matchers, assumptions and exception testing capabilities, and support for nested and parameterized tests. JUnit 5 also overhauls extension mechanisms and introduces extension points for customization. While still in development, JUnit 5 is moving to an API based on extensions and customization points rather than the runner approach used in JUnit 4.
Использование GMock для обеспечения спокойной и сытой жизни разработчика. Обзор как верхушки так и некоторых подводных частей GMock. Разбор возможностей фреймворка на примерах.
The document provides examples of Java code using try, catch, throw, and exceptions to handle errors and exceptions. Program 36 introduces a try-catch block to handle potential InputMismatchExceptions from user input. Program 37 uses try-catch-finally to handle an ArithmeticException from division by zero and ensure the finally block always executes. Program 38 demonstrates multiple catch blocks to handle different exception types.
Here are some suggestions to improve the test method name:
- shouldReturnNullWhenQueryReturnsNull
- shouldPassNullFromDaoWhenQueryReturnsNull
Using "should" makes the intent clearer - we expect the method to return null under certain conditions. Describing those conditions ("when query returns null") in the name provides more context than a generic "testQuery".
Overall, test method names should clearly communicate what is being tested and under what conditions we expect the test to pass or fail. This helps readers understand the purpose and focus of each test.
The document discusses exception handling in Scala code. It provides examples of the original code with try/catch blocks, a modified version that handles specific exception types in catch, and an improved approach that centralizes exception handling. The improved approach throws a custom CandAllExceptions for any exception in the catch block, allowing exceptions to be handled in one place rather than throughout the code. It also discusses best practices like using ProcessLogger instead of Process to catch process exceptions, creating custom exceptions with messages and causes, and annotating methods with @throws only if calling from Java.
Test-driven development for TYPO3 (T3DD11)Oliver Klee
This document discusses test-driven development for TYPO3. It provides an overview of unit testing, describing how automated testing is faster and more reliable than manual testing. It also summarizes a real estate manager extension that contains over 1600 tests that run in under 60 seconds. The document then discusses key testing concepts and terminology like test cases, test suites, assertions, and the lifecycle of unit tests. It promotes a test-first development approach and describes how to write meaningful, well-named unit tests. Finally, it outlines how the TYPO3 testing framework can fake or simulate different parts of an application to enable isolated and repeatable testing.
The Impact of Test Case Summaries on Bug Fixing Performance: An Empirical Inv...Sebastiano Panichella
Automated test generation tools have been widely investigated
with the goal of reducing the cost of testing activities.
However, generated tests have been shown not to help developers in detecting and finding more bugs even though
they reach higher structural coverage compared to manual
testing. The main reason is that generated tests are di-
cult to understand and maintain. Our paper proposes an
approach, coined TestDescriber, which automatically generates
test case summaries of the portion of code exercised by
each individual test, thereby improving understandability.
We argue that this approach can complement the current
techniques around automated unit test generation or search based techniques designed to generate a possibly minimal set
of test cases. In evaluating our approach we found that (1)
developers find twice as many bugs, and (2) test case summaries
significantly improve the comprehensibility of test
cases, which is considered particularly useful by developers.
This document provides an introduction to using the Google Test framework for unit testing C++ code. It begins with an example of a simple test for a function called calc_isect. It then demonstrates how to add assertions to tests, use test fixtures to reduce duplicated setup code, and generate parameterized tests. The document also covers best practices for test organization, installing and using Google Test, and some key features like XML output and selecting subsets of tests. Overall, the document serves as a tutorial for getting started with the Google Test framework for writing and running unit tests in C++ projects.
The document summarizes the key differences between JUnit 4 and JUnit 5 (alpha). Some of the main changes in JUnit 5 include updated annotations like @Test, support for lambda-based assertions using Hamcrest matchers, assumptions and exception testing capabilities, and support for nested and parameterized tests. JUnit 5 also overhauls extension mechanisms and introduces extension points for customization. While still in development, JUnit 5 is moving to an API based on extensions and customization points rather than the runner approach used in JUnit 4.
Использование GMock для обеспечения спокойной и сытой жизни разработчика. Обзор как верхушки так и некоторых подводных частей GMock. Разбор возможностей фреймворка на примерах.
The document provides examples of Java code using try, catch, throw, and exceptions to handle errors and exceptions. Program 36 introduces a try-catch block to handle potential InputMismatchExceptions from user input. Program 37 uses try-catch-finally to handle an ArithmeticException from division by zero and ensure the finally block always executes. Program 38 demonstrates multiple catch blocks to handle different exception types.
Here are some suggestions to improve the test method name:
- shouldReturnNullWhenQueryReturnsNull
- shouldPassNullFromDaoWhenQueryReturnsNull
Using "should" makes the intent clearer - we expect the method to return null under certain conditions. Describing those conditions ("when query returns null") in the name provides more context than a generic "testQuery".
Overall, test method names should clearly communicate what is being tested and under what conditions we expect the test to pass or fail. This helps readers understand the purpose and focus of each test.
The document discusses exception handling in Scala code. It provides examples of the original code with try/catch blocks, a modified version that handles specific exception types in catch, and an improved approach that centralizes exception handling. The improved approach throws a custom CandAllExceptions for any exception in the catch block, allowing exceptions to be handled in one place rather than throughout the code. It also discusses best practices like using ProcessLogger instead of Process to catch process exceptions, creating custom exceptions with messages and causes, and annotating methods with @throws only if calling from Java.
The document discusses various techniques for unit testing concurrent code, including using JUnit, TestNG, and a custom ThreadWeaver framework to test for threading issues in a FlawedList implementation. It also covers using jcstress for concurrency stress testing and notes that jcstress results may vary between runs and depend on processor architecture memory access semantics.
The document discusses behavior driven development (BDD) and test-driven development (TDD). It shows an example of incrementally developing a FizzBuzz program using TDD and JUnit tests. First, a single test is written to verify the output for the number 1. Then tests are added and code is modified to pass each new test, building up the full FizzBuzz logic over multiple test/code iterations. The document also discusses differences between traditional TDD testing and BDD-style testing, where test method names are written as sentences describing expected behavior.
This document provides an overview of Spock, a testing framework for Java and Groovy. It describes how to include Spock tests in a project, run Spock tests, debug Spock tests, view test coverage, and integrate Spock tests with Sonar. It also explains Spock specifications, feature methods, blocks like setup, when/then, expect, and cleanup. It demonstrates how to write conditions, handle exceptions, create helper methods, mocks, stubs, and spies in Spock tests.
This document provides an overview and agenda for a presentation about Java. It discusses Java history, object-oriented programming concepts like classes and interfaces, inheritance and polymorphism, exception handling, primitive types and wrappers, inner classes, generics, and new features introduced since Java 5 such as varargs, enhanced for loops, annotations, and auto boxing/unboxing. The presentation covers these topics over multiple slides with code examples.
Java 7 Launch Event at LyonJUG, Lyon France. Fork / Join framework and Projec...julien.ponge
The document discusses new features in Java SE 7 including the Fork/Join framework for parallel programming, language evolutions through Project Coin such as try-with-resources statements, and diamond syntax for generic types which simplifies generic class instance creation. It also covers varargs syntax simplification and restrictions on using diamond syntax with anonymous inner classes.
This document summarizes new features and enhancements in Java 7 including Project Coin, NIO.2, invokedynamic, Fork/Join framework, and concurrency utilities. It discusses how these features make threads, parallelism, and concurrency easier to work with in Java. Code examples are provided to illustrate the use of ForkJoinPool, Callable, and try-with-resources statements.
This document provides an overview and examples of using Google Guava, an open-source Java library that includes common libraries useful for writing Java code. It highlights some key classes and methods in Guava, including annotations, strings, collections, I/O, and more. Code samples demonstrate using Guava features like predicates, sets, files, and InetAddress utilities.
The document discusses Simple API for XML (SAX), an event-based model for parsing XML documents. SAX involves defining handler methods that are called when XML parsing events occur, like start elements or character data. This allows applications to process XML documents as they are parsed without loading the entire document into memory. The example shows a SAX parser that outputs a tree structure of an XML document by overriding handler methods.
The document discusses test-driven development for TYPO3 and describes how to use unit testing and the testing framework in TYPO3. It covers key testing concepts like test cases, assertions, and test suites. It also provides an overview of the testing lifecycle and recommends a test-first development approach. Finally, it demonstrates how the testing framework can be used to fake different parts of TYPO3 like records, relations, pages, and frontend users.
The document describes how JBoss Drools can be used to model business rules and requirements by defining rules using a domain-specific language that can validate objects like orders against the defined rules. Drools provides features like declarative rule patterns, object mapping, functions, queries, and templates to define complex validation logic in a more readable way compared to implementing the same logic in Java. Drools also supports defining metadata, classes and integrating with a rules engine and working memory to efficiently execute rules on facts.
Conf soat tests_unitaires_Mockito_jUnit_170113SOAT
Vous subissez les régressions à chaque livraison ? Vous ne voyez pas l’intérêt des tests unitaires car ils ne servent qu’à tester des additions ? Si c’est le cas, suivez David dans la quête du Test Driven Development. Nous rencontrerons pléthore d'ennemies contre lesquels nous aurons à combattre : bugs, complexité, code statique, couplage fort. Ils essaieront de nous barrer la route, mais heureusement, nous pourrons compter sur nos alliés jUnit, Mockito, refactoring et injection/dépendance
Spock is a testing framework written in Groovy that allows developers to write tests in a business readable domain specific language. It combines the benefits of specification-based testing and mock-based testing. Some key features of Spock include the ability to write feature methods with given, when, and then blocks; use fixtures for setup and cleanup; parameterize tests with data tables in where blocks; make assertions about interactions with mock objects; and write tests in a BDD style with descriptive language. Spock's tests are themselves a good source of documentation on how to write and use Spock tests.
soft-shake.ch - Java SE 7: The Fork/Join Framework and Project Coinsoft-shake.ch
Julien Ponge
This talk introduces part of the Java SE 7 novelties. The fork/join framework aims at making parallel programming simpler, while Project Coin brings a set of subtle yet useful changes to the Java programming language.
http://soft-shake.ch/2011/conference/sessions/java/2011/09/06/java7.html
Spock is a Groovy-based testing framework that provides features for writing tests in a clear, expressive, and highly readable manner. Some key features highlighted in the document include:
- Spock tests are structured into blocks like "given", "when", "then" that give tests a clear structure and meaning.
- Spock includes powerful and easy to read assertion methods as well as the ability to display diffs when expectations are not met.
- Spock supports mocking and stubbing of dependencies in a simple way.
- Data-driven testing is first-class in Spock through features like the "where" block that allows input test data to be specified in a table.
What can be done with Java, but should better be done with Erlang (@pavlobaron)Pavlo Baron
Erlang excels at building distributed, fault-tolerant, concurrent applications due to its lightweight process model and built-in support for distribution. However, Java is more full-featured and is generally a better choice for applications that require more traditional object-oriented capabilities or need to interface with existing Java libraries and frameworks. Both languages have their appropriate uses depending on the requirements of the specific application being developed.
1. The document discusses good and bad practices for writing unit tests. It emphasizes that tests should verify the expected behavior, fail clearly when something goes wrong, and use mocks and isolation to focus on the code being tested.
2. Some examples of bad tests shown include tests that don't make assertions or assertions that don't provide useful information on failure. Real objects are also used instead of mocks, obscuring the test.
3. Good practices include using mocks to isolate the code being tested, making sure tests fail clearly when something goes wrong, and focusing tests on expected behavior through clear assertions. Automated testing, fixing broken tests, and mastering testing tools are also emphasized.
Slides from my Confitura 2012 presentation. The issues discussed during the talk will be described in my new (free!) ebook - see https://github.com/tomekkaczanowski/bad-tests-good-tests
Software Testing - Invited Lecture at UNSW Sydneyjulien.ponge
This document provides an overview of software testing concepts and the JUnit testing framework. It discusses the importance of testing, different types of testing, unit testing with JUnit, best practices for writing tests, integrating tests into builds with Ant and Maven, and logging. Examples of JUnit tests are also provided. The key points covered are:
- Why testing is important to find bugs, prevent regressions, and allow for refactoring
- Unit testing, functional testing, and other types of testing
- How to write automated unit tests with JUnit
- Best practices like testing edge cases, achieving good code coverage
- Integrating tests into builds with Ant and Maven
- Using logging frameworks like Log
Unit testing with PHPUnit allows developers to automate testing of classes and functions. Tests can validate expected outputs and behaviors and catch bugs. PHPUnit provides assertions to validate results and annotations to organize tests, mark them as incomplete, or specify expected exceptions. Fixtures can set up and tear down test environments and data. Writing thorough automated tests improves code quality and prevents regressions.
JUnit is a unit testing framework for Java that allows developers to write and run repeatable automated tests to determine whether code is functioning as intended. Key aspects of JUnit include writing tests before code via test-driven development, annotations for metadata and configuration of tests, and the ability to isolate tests from external dependencies using stubs and mocks. JUnit helps improve code quality and avoid regressions by identifying problems early in the development cycle.
The document discusses various techniques for unit testing concurrent code, including using JUnit, TestNG, and a custom ThreadWeaver framework to test for threading issues in a FlawedList implementation. It also covers using jcstress for concurrency stress testing and notes that jcstress results may vary between runs and depend on processor architecture memory access semantics.
The document discusses behavior driven development (BDD) and test-driven development (TDD). It shows an example of incrementally developing a FizzBuzz program using TDD and JUnit tests. First, a single test is written to verify the output for the number 1. Then tests are added and code is modified to pass each new test, building up the full FizzBuzz logic over multiple test/code iterations. The document also discusses differences between traditional TDD testing and BDD-style testing, where test method names are written as sentences describing expected behavior.
This document provides an overview of Spock, a testing framework for Java and Groovy. It describes how to include Spock tests in a project, run Spock tests, debug Spock tests, view test coverage, and integrate Spock tests with Sonar. It also explains Spock specifications, feature methods, blocks like setup, when/then, expect, and cleanup. It demonstrates how to write conditions, handle exceptions, create helper methods, mocks, stubs, and spies in Spock tests.
This document provides an overview and agenda for a presentation about Java. It discusses Java history, object-oriented programming concepts like classes and interfaces, inheritance and polymorphism, exception handling, primitive types and wrappers, inner classes, generics, and new features introduced since Java 5 such as varargs, enhanced for loops, annotations, and auto boxing/unboxing. The presentation covers these topics over multiple slides with code examples.
Java 7 Launch Event at LyonJUG, Lyon France. Fork / Join framework and Projec...julien.ponge
The document discusses new features in Java SE 7 including the Fork/Join framework for parallel programming, language evolutions through Project Coin such as try-with-resources statements, and diamond syntax for generic types which simplifies generic class instance creation. It also covers varargs syntax simplification and restrictions on using diamond syntax with anonymous inner classes.
This document summarizes new features and enhancements in Java 7 including Project Coin, NIO.2, invokedynamic, Fork/Join framework, and concurrency utilities. It discusses how these features make threads, parallelism, and concurrency easier to work with in Java. Code examples are provided to illustrate the use of ForkJoinPool, Callable, and try-with-resources statements.
This document provides an overview and examples of using Google Guava, an open-source Java library that includes common libraries useful for writing Java code. It highlights some key classes and methods in Guava, including annotations, strings, collections, I/O, and more. Code samples demonstrate using Guava features like predicates, sets, files, and InetAddress utilities.
The document discusses Simple API for XML (SAX), an event-based model for parsing XML documents. SAX involves defining handler methods that are called when XML parsing events occur, like start elements or character data. This allows applications to process XML documents as they are parsed without loading the entire document into memory. The example shows a SAX parser that outputs a tree structure of an XML document by overriding handler methods.
The document discusses test-driven development for TYPO3 and describes how to use unit testing and the testing framework in TYPO3. It covers key testing concepts like test cases, assertions, and test suites. It also provides an overview of the testing lifecycle and recommends a test-first development approach. Finally, it demonstrates how the testing framework can be used to fake different parts of TYPO3 like records, relations, pages, and frontend users.
The document describes how JBoss Drools can be used to model business rules and requirements by defining rules using a domain-specific language that can validate objects like orders against the defined rules. Drools provides features like declarative rule patterns, object mapping, functions, queries, and templates to define complex validation logic in a more readable way compared to implementing the same logic in Java. Drools also supports defining metadata, classes and integrating with a rules engine and working memory to efficiently execute rules on facts.
Conf soat tests_unitaires_Mockito_jUnit_170113SOAT
Vous subissez les régressions à chaque livraison ? Vous ne voyez pas l’intérêt des tests unitaires car ils ne servent qu’à tester des additions ? Si c’est le cas, suivez David dans la quête du Test Driven Development. Nous rencontrerons pléthore d'ennemies contre lesquels nous aurons à combattre : bugs, complexité, code statique, couplage fort. Ils essaieront de nous barrer la route, mais heureusement, nous pourrons compter sur nos alliés jUnit, Mockito, refactoring et injection/dépendance
Spock is a testing framework written in Groovy that allows developers to write tests in a business readable domain specific language. It combines the benefits of specification-based testing and mock-based testing. Some key features of Spock include the ability to write feature methods with given, when, and then blocks; use fixtures for setup and cleanup; parameterize tests with data tables in where blocks; make assertions about interactions with mock objects; and write tests in a BDD style with descriptive language. Spock's tests are themselves a good source of documentation on how to write and use Spock tests.
soft-shake.ch - Java SE 7: The Fork/Join Framework and Project Coinsoft-shake.ch
Julien Ponge
This talk introduces part of the Java SE 7 novelties. The fork/join framework aims at making parallel programming simpler, while Project Coin brings a set of subtle yet useful changes to the Java programming language.
http://soft-shake.ch/2011/conference/sessions/java/2011/09/06/java7.html
Spock is a Groovy-based testing framework that provides features for writing tests in a clear, expressive, and highly readable manner. Some key features highlighted in the document include:
- Spock tests are structured into blocks like "given", "when", "then" that give tests a clear structure and meaning.
- Spock includes powerful and easy to read assertion methods as well as the ability to display diffs when expectations are not met.
- Spock supports mocking and stubbing of dependencies in a simple way.
- Data-driven testing is first-class in Spock through features like the "where" block that allows input test data to be specified in a table.
What can be done with Java, but should better be done with Erlang (@pavlobaron)Pavlo Baron
Erlang excels at building distributed, fault-tolerant, concurrent applications due to its lightweight process model and built-in support for distribution. However, Java is more full-featured and is generally a better choice for applications that require more traditional object-oriented capabilities or need to interface with existing Java libraries and frameworks. Both languages have their appropriate uses depending on the requirements of the specific application being developed.
1. The document discusses good and bad practices for writing unit tests. It emphasizes that tests should verify the expected behavior, fail clearly when something goes wrong, and use mocks and isolation to focus on the code being tested.
2. Some examples of bad tests shown include tests that don't make assertions or assertions that don't provide useful information on failure. Real objects are also used instead of mocks, obscuring the test.
3. Good practices include using mocks to isolate the code being tested, making sure tests fail clearly when something goes wrong, and focusing tests on expected behavior through clear assertions. Automated testing, fixing broken tests, and mastering testing tools are also emphasized.
Slides from my Confitura 2012 presentation. The issues discussed during the talk will be described in my new (free!) ebook - see https://github.com/tomekkaczanowski/bad-tests-good-tests
Software Testing - Invited Lecture at UNSW Sydneyjulien.ponge
This document provides an overview of software testing concepts and the JUnit testing framework. It discusses the importance of testing, different types of testing, unit testing with JUnit, best practices for writing tests, integrating tests into builds with Ant and Maven, and logging. Examples of JUnit tests are also provided. The key points covered are:
- Why testing is important to find bugs, prevent regressions, and allow for refactoring
- Unit testing, functional testing, and other types of testing
- How to write automated unit tests with JUnit
- Best practices like testing edge cases, achieving good code coverage
- Integrating tests into builds with Ant and Maven
- Using logging frameworks like Log
Unit testing with PHPUnit allows developers to automate testing of classes and functions. Tests can validate expected outputs and behaviors and catch bugs. PHPUnit provides assertions to validate results and annotations to organize tests, mark them as incomplete, or specify expected exceptions. Fixtures can set up and tear down test environments and data. Writing thorough automated tests improves code quality and prevents regressions.
JUnit is a unit testing framework for Java that allows developers to write and run repeatable automated tests to determine whether code is functioning as intended. Key aspects of JUnit include writing tests before code via test-driven development, annotations for metadata and configuration of tests, and the ability to isolate tests from external dependencies using stubs and mocks. JUnit helps improve code quality and avoid regressions by identifying problems early in the development cycle.
This document discusses various techniques for unit testing in Java with JUnit, including naming tests clearly, using Hamcrest matchers for assertions, writing parameterized tests, using JUnit rules, and measuring code coverage. It provides examples of how to write tests that follow best practices and leverage JUnit's capabilities for parameterized testing, timeouts, error collection, and more. It also discusses running tests in parallel and measuring code coverage in IDEs like IntelliJ and Eclipse.
This document discusses best practices for writing clean tests, including naming conventions, test structure, and principles such as keeping tests focused on individual behaviors, avoiding logic in tests, and preferring to test public APIs over private methods. It recommends giving tests clear and descriptive names, using a Given-When-Then structure, and creating reusable helper functions to prepare test data. Tests should have a single assert per scenario and verify only the relevant method arguments for the behavior being tested. Following these guidelines helps produce tests that are easy to understand and maintain.
A lecture about type expressiveness using the Either monad in C#. It's a discussion about the problem that arises from a lack of a built-in mechanism that allows you to express that a function is likely to fail. We implement a solution to this problem and see how it allows us to write production-ready code.
A presentation on JUnit Pioneer given at Fortitude Technologies on Mar. 4, 2021. JUnit Pioneer is an extension library for JUnit 5 (Jupiter).
Sample code on GitHub at:
https://github.com/sleberknight/junit-pioneering-presentation-code
JUnit Pioneer home page:
https://junit-pioneer.org
Unit testing patterns for concurrent codeDror Helper
Getting started with unit testing is not hard, the only problem is that most programs are more than a simple calculator with two parameters and a returns value that is easy to verify.
Writing unit tests for multi-threaded code is harder still.
Over the years I discovered useful patterns that helped me to test multi-threaded and asynchronous code and enabled the creation of deterministic, simple and robust unit tests.
Come learn how to test code that uses concurrency and parallelism – so that the excuses of not writing unit tests for such code would become as obsolete as a single core processors.
JUnit is the de facto standard in Java testing. Yet many advanced JUnit features are little known and poorly understood. This session reviews some lesser-known features of JUnit, along with a few associated libraries, that can make your unit tests more powerful, expressive, and fun. The session is intended for Java developers, lead developers, and architects trying to introduce good testing practices into their teams.
Next Generation Developer Testing: Parameterized TestingTao Xie
The document discusses parameterized unit testing (PUT) as an improvement over conventional unit tests (CUTs). PUTs separate test specifications from test data generation, addressing issues with CUTs like low fault detection and redundant tests. PUTs can be represented as universally quantified conditional axioms. Major steps to retrofit CUTs to PUTs include parameterizing values, generalizing test oracles, and adding assumptions. Examples demonstrate how a CUT can be generalized to a PUT to improve test coverage. Parameterized testing is now supported by various frameworks like JUnit and Visual Studio.
This document discusses JavaScript testing and provides examples of writing tests and using testing frameworks like QUnit and JSUnit. It covers:
- Why test JavaScript code due to cross-browser issues and bugs
- Components of a test suite including tests, assertions, and a test runner
- Examples of writing basic tests with assertions and handling asynchronous tests
- Popular JavaScript testing frameworks like QUnit, JSUnit, YUITest
The document discusses various features of EasyMock, a Java testing framework for creating mock objects to test code in isolation, including how to create different types of mocks, define return values and argument matchers, and integrate EasyMock with the Unitils testing framework. It provides examples of using EasyMock to mock objects, define expected method calls and return values, and verify interactions for unit testing purposes.
We all want "better" test suites. But what makes for a good test suite? Certainly, test suites ought to aim for good coverage, at least at the statement coverage level. To be useful, test suites should run quickly enough to provide timely feedback.
This talk will investigate a number of other dimensions on which to evaluate test suites. The talk claims that better test suites are more maintainable, more usable (for instance, because they run faster, or use fewer resources), and have fewer unjustified failures. In this talk, I'll present and synthesize facts about 10 open-source test suites (from 8,000 to 246,000 lines of code) and evaluate how they are doing.
This document defines and describes various types of test doubles (dummy objects, fakes, stubs, mocks, spies) that are used for testing purposes. It provides examples of how to create mocks using Mockito, stub behaviors for mocks, verify interactions with mocks, and some limitations of mocking with Mockito.
Mocking allows testing components in isolation without dependencies like databases or file systems. It emphasizes single responsibility by allowing classes to behave consistently regardless of dependency implementations. Mockito provides mocking capabilities like stubbing mock methods to return values or exceptions and verifying mock method calls and arguments. It supports argument matchers, verifying call order and number of invocations, and spying to selectively mock certain methods of real objects.
This document provides an overview of best practices for writing Java code. It discusses topics like immutability, using libraries like Guava and Joda-Time, avoiding nulls, closing resources properly, using prepared statements to prevent SQL injection, and many other practices. The document emphasizes writing code that is readable, maintainable, efficient and avoids common pitfalls. It also provides resources for tools that can analyze code and help identify areas that don't follow best practices.
The document introduces unit testing with JUnit by walking through an example of writing tests for a Conway's Game of Life Cell class. It shows how to:
1) Write an initial test that fails to compile due to missing code.
2) Add just enough code (a no-arg Cell constructor and isAlive() method) to get the test to compile.
3) Run the test and ensure it fails as expected before the code is implemented.
4) Continue writing tests and extending the Cell class to pass all tests and achieve the desired behavior.
Unit & Automation Testing in Android - Stanislav Gatsev, MelonbeITconference
Stanislav Gatsev presents on unit and automation testing on Android. He discusses why automation testing is important for saving time, improving code quality, and supporting live documentation. He covers using JUnit and Mockito for testing, as well as activity testing with ActivityInstrumentationTestCase2 and user interface testing with Robotium. Mock objects are used to replace dependencies and allow testing in isolation. Examples are provided of writing unit tests, activity tests, and tests using Robotium to simulate user interactions.
JEEConf 2017 - Having fun with JavassistAnton Arhipov
Javassist makes Java bytecode manipulation simple. At ZeroTurnaround we use Javassist a lot to implement the integrations for our tools.
In this talk we will go through the examples of how Javassist can be applied to alter the applications behavior and do all kind of fun stuff with it.
Why is it interesting? Because while trying to do unusual things in Java, you learn much more about the language and the platform itself and learning about Javassist will actually make you a better Java developer!
Курс "Программирование на Java". Лекция 07 "Бонус - Головоломки".
Java Puzzlers. Синхронизация и многопоточность. Примитивы. Объекты и классы. Исключения и финализация.
МФТИ, 2016 год. Лектор - Лаврентьев Федор Сергеевич
Microservice Teams - How the cloud changes the way we workSven Peters
A lot of technical challenges and complexity come with building a cloud-native and distributed architecture. The way we develop backend software has fundamentally changed in the last ten years. Managing a microservices architecture demands a lot of us to ensure observability and operational resiliency. But did you also change the way you run your development teams?
Sven will talk about Atlassian’s journey from a monolith to a multi-tenanted architecture and how it affected the way the engineering teams work. You will learn how we shifted to service ownership, moved to more autonomous teams (and its challenges), and established platform and enablement teams.
What to do when you have a perfect model for your software but you are constrained by an imperfect business model?
This talk explores the challenges of bringing modelling rigour to the business and strategy levels, and talking to your non-technical counterparts in the process.
Baha Majid WCA4Z IBM Z Customer Council Boston June 2024.pdfBaha Majid
IBM watsonx Code Assistant for Z, our latest Generative AI-assisted mainframe application modernization solution. Mainframe (IBM Z) application modernization is a topic that every mainframe client is addressing to various degrees today, driven largely from digital transformation. With generative AI comes the opportunity to reimagine the mainframe application modernization experience. Infusing generative AI will enable speed and trust, help de-risk, and lower total costs associated with heavy-lifting application modernization initiatives. This document provides an overview of the IBM watsonx Code Assistant for Z which uses the power of generative AI to make it easier for developers to selectively modernize COBOL business services while maintaining mainframe qualities of service.
Odoo releases a new update every year. The latest version, Odoo 17, came out in October 2023. It brought many improvements to the user interface and user experience, along with new features in modules like accounting, marketing, manufacturing, websites, and more.
The Odoo 17 update has been a hot topic among startups, mid-sized businesses, large enterprises, and Odoo developers aiming to grow their businesses. Since it is now already the first quarter of 2024, you must have a clear idea of what Odoo 17 entails and what it can offer your business if you are still not aware of it.
This blog covers the features and functionalities. Explore the entire blog and get in touch with expert Odoo ERP consultants to leverage Odoo 17 and its features for your business too.
An Overview of Odoo ERP
Odoo ERP was first released as OpenERP software in February 2005. It is a suite of business applications used for ERP, CRM, eCommerce, websites, and project management. Ten years ago, the Odoo Enterprise edition was launched to help fund the Odoo Community version.
When you compare Odoo Community and Enterprise, the Enterprise edition offers exclusive features like mobile app access, Odoo Studio customisation, Odoo hosting, and unlimited functional support.
Today, Odoo is a well-known name used by companies of all sizes across various industries, including manufacturing, retail, accounting, marketing, healthcare, IT consulting, and R&D.
The latest version, Odoo 17, has been available since October 2023. Key highlights of this update include:
Enhanced user experience with improvements to the command bar, faster backend page loading, and multiple dashboard views.
Instant report generation, credit limit alerts for sales and invoices, separate OCR settings for invoice creation, and an auto-complete feature for forms in the accounting module.
Improved image handling and global attribute changes for mailing lists in email marketing.
A default auto-signature option and a refuse-to-sign option in HR modules.
Options to divide and merge manufacturing orders, track the status of manufacturing orders, and more in the MRP module.
Dark mode in Odoo 17.
Now that the Odoo 17 announcement is official, let’s look at what’s new in Odoo 17!
What is Odoo ERP 17?
Odoo 17 is the latest version of one of the world’s leading open-source enterprise ERPs. This version has come up with significant improvements explained here in this blog. Also, this new version aims to introduce features that enhance time-saving, efficiency, and productivity for users across various organisations.
Odoo 17, released at the Odoo Experience 2023, brought notable improvements to the user interface and added new functionalities with enhancements in performance, accessibility, data analysis, and management, further expanding its reach in the market.
UI5con 2024 - Bring Your Own Design SystemPeter Muessig
How do you combine the OpenUI5/SAPUI5 programming model with a design system that makes its controls available as Web Components? Since OpenUI5/SAPUI5 1.120, the framework supports the integration of any Web Components. This makes it possible, for example, to natively embed own Web Components of your design system which are created with Stencil. The integration embeds the Web Components in a way that they can be used naturally in XMLViews, like with standard UI5 controls, and can be bound with data binding. Learn how you can also make use of the Web Components base class in OpenUI5/SAPUI5 to also integrate your Web Components and get inspired by the solution to generate a custom UI5 library providing the Web Components control wrappers for the native ones.
Project Management: The Role of Project Dashboards.pdfKarya Keeper
Project management is a crucial aspect of any organization, ensuring that projects are completed efficiently and effectively. One of the key tools used in project management is the project dashboard, which provides a comprehensive view of project progress and performance. In this article, we will explore the role of project dashboards in project management, highlighting their key features and benefits.
E-commerce Development Services- Hornet DynamicsHornet Dynamics
For any business hoping to succeed in the digital age, having a strong online presence is crucial. We offer Ecommerce Development Services that are customized according to your business requirements and client preferences, enabling you to create a dynamic, safe, and user-friendly online store.
The Rising Future of CPaaS in the Middle East 2024Yara Milbes
Explore "The Rising Future of CPaaS in the Middle East in 2024" with this comprehensive PPT presentation. Discover how Communication Platforms as a Service (CPaaS) is transforming communication across various sectors in the Middle East.
Everything You Need to Know About X-Sign: The eSign Functionality of XfilesPr...XfilesPro
Wondering how X-Sign gained popularity in a quick time span? This eSign functionality of XfilesPro DocuPrime has many advancements to offer for Salesforce users. Explore them now!
A neural network is a machine learning program, or model, that makes decisions in a manner similar to the human brain, by using processes that mimic the way biological neurons work together to identify phenomena, weigh options and arrive at conclusions.
14 th Edition of International conference on computer visionShulagnaSarkar2
About the event
14th Edition of International conference on computer vision
Computer conferences organized by ScienceFather group. ScienceFather takes the privilege to invite speakers participants students delegates and exhibitors from across the globe to its International Conference on computer conferences to be held in the Various Beautiful cites of the world. computer conferences are a discussion of common Inventions-related issues and additionally trade information share proof thoughts and insight into advanced developments in the science inventions service system. New technology may create many materials and devices with a vast range of applications such as in Science medicine electronics biomaterials energy production and consumer products.
Nomination are Open!! Don't Miss it
Visit: computer.scifat.com
Award Nomination: https://x-i.me/ishnom
Conference Submission: https://x-i.me/anicon
For Enquiry: Computer@scifat.com
6. Strive for Clean Code
if (getAgeInYears() >= 62 && early)
payment = getEarlyPay();
else if (getAgeInYears() >= 65 && !early)
payment = getRegPay();
else
payment = 0;
int getAgeInYears() {
int age = getDate().year – dob.year;
if (getDate().month >= dob.month) age++;
return age;
}
Magic
numbers
7. Strive for Clean Code
final static int EARLY_RETIREMENT_AGE = 62;
final static int REGULAR_RETIREMENT_AGE = 65;
if (getAgeInYears() >= EARLY_RETIREMENT_AGE && early)
payment = getEarlyPay();
else if (getAgeInYears() >= REGULAR_RETIREMENT_AGE && !early)
payment = getRegPay();
else
payment = 0; Complex conditional
8. Strive for Clean Code
final static int EARLY_RETIREMENT_AGE = 62;
final static int REGULAR_RETIREMENT_AGE = 65;
if (isCollectingEarlyRetirement())
payment = getEarlyPay();
else if (isCollectingRegularRetirement())
payment = getRegPay();
else
payment = 0;
boolean isCollectingEarlyRetirement() {
return early && getAgeInYears() >= EARLY_RETIREMENT_AGE);
}
Ambiguous
names
9. Strive for Clean Code
final static int EARLY_RETIREMENT_AGE = 62;
final static int REGULAR_RETIREMENT_AGE = 65;
if (isCollectingEarlyRetirement())
payment = getEarlyRetirementPayment();
else if (isCollectingRegularRetirement())
payment = getRegularRetirementPayment();
else
payment = 0;
boolean isCollectingEarlyRetirement() {
return electedEarlyRetirement && getAgeInYears() >= EARLY_RETIREMENT_AGE);
}
10. Unit Tests are Code
Choose good method names
Keep methods short and coherent
Avoid magic numbers
Avoid long argument lists
Avoid duplication
11. Test One Thing Per Test
@Test
public void afterCellAdded_boardIsAtLeast10x10() {
Board board = new Board();
board.addCell(0, 0);
assertThat(board.getHeight(), is(greaterThan(10));
assertThat(board.getWidth(), is(greaterThan(10));
}
Name describes exactly what is being tested
Set up (could be part of test class setup)
Operation to test
Validation