Thomas Ferris Nicolaisen - Objectware. Sprint TestContext Framework Thomas Ferris Nicolaisen Objectware JavAcademy desember 2007.

Slides:



Advertisements
Similar presentations
Bowling Game Kata Object Mentor, Inc. fitnesse.org Copyright 2005 by Object Mentor, Inc All copies must retain this page unchanged.
Advertisements

Mock junit framework uses pre- populated mock java objects instead of live database connection for executing the unit test cases.
Lightning Talk by Ted Young. What is Integration Testing?
For(int i = 1; i
Programming In C++ Spring Semester 2013 Lecture 3 Programming In C++, Lecture 3 By Umer Rana.
Do-while Loops Programming. COMP102 Prog Fundamentals I: do-while Loops /Slide 2 The do-while Statement l Syntax do action while (condition) l How it.
Introduction to Assembly language
J-Unit Framework.
Intermediate Spring Matt Wheeler. Notes This is a training NOT a presentation Please ask questions Prerequisites – Introduction to Java Stack – Basic.
JUnit intro Kalvis Apsitis. What are “Programmer Tests”? Programmer Testing is the testing performed by a developer with the goal of verifying the correct.
Objectives: Test Options JUnit Testing Framework TestRunners Test Cases and Test Suites Test Fixtures JUnit.
24-Jun-15 JUnit. 2 Test suites Obviously you have to test your code to get it working in the first place You can do ad hoc testing (running whatever tests.
TDD Test-Driven Development. JUnit 4.0 To use annotations need to import org.junit.Test To use assertion need to import org.junit.Assert.* No need to.
14-Jul-15 JUnit 4. Comparing JUnit 3 to JUnit 4 All the old assertXXX methods are the same Most things are about equally easy JUnit 4 makes it easier.
Unit Testing Discussion C. Unit Test ● public Method is smallest unit of code ● Input/output transformation ● Test if the method does what it claims ●
Programmer Testing Testing all things Java using JUnit and extensions.
Unit Testing & Defensive Programming. F-22 Raptor Fighter.
TestNG … and improving use of JUnit Dec 11, 2008 C. Gordon Huffman.
Maven & Bamboo CONTINUOUS INTEGRATION. QA in a large organization In a large organization that manages over 100 applications and over 20 developers, implementing.
Coding Methodology How to Design Code. © 2005 MIT-Africa Internet Technology Initiative Pay Attention to Detail When implementing or using APIs details.
Designing For Testability. Incorporate design features that facilitate testing Include features to: –Support test automation at all levels (unit, integration,
Testing in Extreme Programming
Spring core v3.x Prepared by: Nhan Le. History v3.0 Spring Expression Language Java based bean metadata v3.1 Cache Abstraction Bean Definition Profile.
CSC 216/001 Lecture 4. Unit Testing  Why is it called “unit” testing?  When should tests be written?  Before the code for a class is written.  After.
Junit At the forefront of Test Driven Development.
Spring 2008 Mark Fontenot CSE 1341 Principles of Computer Science I Note Set 10.
Effective Test Driven Database Development Gojko Adzic
1.  “To write test cases for every non-trivial function or method in the module so that each test case is [as] separate from the others [as] possible.”
Implement Unit Test Framework for Application running on a Pocket PC 2003 device Durga Kulkarni Cyberonics Inc August 28, 2009.
1.  Writing snippets of code that try to use methods (functions) from your program.  Each snippet should test one (and only one) function......by calling.
Introduction to JUnit 3.8 SEG 3203 Winter ‘07 Prepared By Samia Niamatullah.
Refactoring & Testability. Testing in OOP programming No life in flexible methodologies and for refactoring- infected developers without SOME kind of.
Intermediate Spring Matt Wheeler. Notes This is a training NOT a presentation Please ask questions Prerequisites – Introduction to Java Stack – Basic.
INTEGRATION OF BACKBONE.JS WITH SPRING 3.1. Agenda New Features and Enhancements in Spring 3.1 What is Backbone.js and why I should use it Spring 3.1.
Scalatest. 2 Test-Driven Development (TDD) TDD is a technique in which you write the tests before you write the code you want to test This seems backward,
Testing code COMP204. How to? “manual” –Tedious, error-prone, not repeatable “automated” by writing code: –Assertions –Junit.
Spring and DWR Frameworks for Rich Web Enterprise Application Thomas Wiradikusuma Presentation to the 20 th.
JUnit. Introduction JUnit is an open source Java testing framework used to write and run repeatable tests JUnit is integrated with several IDEs, including.
Programming and Problem Solving With Java Copyright 1999, James M. Slack Exceptions Handling Exceptions with try and catch The finally-block The throws.
Test it! Unit, mocking and in-container Meet Arquillian! Ivan St. Ivanov.
1 CSC 216 Lecture 3. 2 Unit Testing  The most basic kind of testing is called unit testing  Why is it called “unit” testing?  When should tests be.
Intoduction to Unit Testing Using JUnit to structure Unit Testing SE-2030 Dr. Mark L. Hornick 1.
EUnit a powerful unit testing framework for Erlang Richard Carlsson Mickaël Rémond.
JUnit in Action SECOND EDITION PETAR TAHCHIEV FELIPE LEME VINCENT MASSOL GARY GREGORY ©2011 by Manning Publications Co. All rights reserved.
Copyright 2007 SpringSource. Copying, publishing or distributing without express written permission is prohibited. Introduction to Data Access with Spring.
Computer Science 320 A First Program in Parallel Java.
Introduction to Computing Concepts Note Set 14. What if… You had to print “I love Java” to the screen 125 times. How? 125 lines of ▫ System.out.println(“I.
Copyright 2007 SpringSource. Copying, publishing or distributing without express written permission is prohibited. Overview of the Spring Framework Introducing.
Automated Testing in Sakai Testing applications and services in isolation and in context Josh Holtzman, UC Berkeley David Haines, University of Michigan.
Int fact (int n) { If (n == 0) return 1; else return n * fact (n – 1); } 5 void main () { Int Sum; : Sum = fact (5); : } Factorial Program Using Recursion.
Testing PA165 Dec 9, 2014 Petr Adámek, Tomáš Pitner.
CSE 143 Lecture 14: testing.
J2EE Lecture 6: Spring – IoC and Dependency Injection
Test Driven Development (TDD)
Dept of Computer Science University of Maryland College Park
Introduction to JUnit CS 4501 / 6501 Software Testing
Testing with Spring Boot
Development and Testing Ch4.1. Algorithm Analysis
Test Driven Development
Handling Exceptions.
Stack Memory 1 (also called Call Stack)
JUnit 28-Nov-18.
Introduction to JUnit CS 4501 / 6501 Software Testing
Testing Acknowledgement: Original slides by Jory Denny.
CSE 143 Lecture 5 More ArrayIntList:
JUnit Reading: various web pages
Designing For Testability
Statements in C Programming
Aspect Oriented Programming
Junit Tests.
Presentation transcript:

Thomas Ferris Nicolaisen - Objectware

Sprint TestContext Framework Thomas Ferris Nicolaisen Objectware JavAcademy desember 2007

Thomas Ferris Nicolaisen - Objectware

”A completely revised integration test framework, with first-class support for JUnit 4 and TestNG ”

Thomas Ferris Nicolaisen - Objectware Spring Spring Test Spring TestContext Framework

Thomas Ferris Nicolaisen - Objectware mv spring-mock spring-test

Thomas Ferris Nicolaisen - Objectware

So how do we do it? pom.xml: (junit 4.4)spring-corespring-beans spring-test spring-tx = 1,1 MB

Thomas Ferris Nicolaisen - = { "testSpring.xml" }) public class TestJUnit4WithSpringTestContextFramework {...

Thomas Ferris Nicolaisen - public void repeatManyTimes() throws Exception { counter++; int numberOfTimesToRepeat = this. getClass(). getMethod("repeatManyTimes"). getAnnotation(Repeat.class).value(); log.trace("Running for the "+counter+"th time"); if (counter > numberOfTimesToRepeat) { fail( "Should not repeat more than 100 times. counter is "+counter); }

Thomas Ferris Nicolaisen - Objectware :17:17,737 DEBUG [no.objectware.jafs.TestJUnit4WithSpringTestContextFramework] :17:18,237 TRACE [no.objectware.jafs.TestJUnit4WithSpringTestContextFramework] :17:18,253 TRACE [no.objectware.jafs.TestJUnit4WithSpringTestContextFramework] :17:18,268 TRACE [no.objectware.jafs.TestJUnit4WithSpringTestContextFramework] :17:18,284 TRACE [no.objectware.jafs.TestJUnit4WithSpringTestContextFramework] :17:18,300 TRACE [no.objectware.jafs.TestJUnit4WithSpringTestContextFramework] :17:18,331 TRACE [no.objectware.jafs.TestJUnit4WithSpringTestContextFramework] :17:18,362 TRACE [no.objectware.jafs.TestJUnit4WithSpringTestContextFramework] -

Thomas Ferris Nicolaisen - Objectware Timeout /** * This test will fail if it takes more than 50 ms to public void doSomethingBeforeTimeout() throws Exception{ int tryChangingMeTo50 = 20; Thread.sleep(tryChangingMeTo50); }

Thomas Ferris Nicolaisen - Objectware Caching public void doSomethingThatDirtiesTheSpringContext() { // can't really come up with anything that screws the context here.. }

Thomas Ferris Nicolaisen - Objectware Springs public void doSomethingThatThrowsAnException() { throw new RuntimeException(); }

Thomas Ferris Nicolaisen - Objectware JUnit4 exception testing /** * This test expects exceptions the JUnit4 way. * It is preferred over the way above. = RuntimeException.class) public void doSomethingElseThatThrowsAnException() { throw new RuntimeException(); }

Thomas Ferris Nicolaisen - Objectware = "mock", value = "true") public void thisWillOnlyBeRunIfTheSystemVariableMockIsTrue() { assertEquals("true", values={"unit-tests", "integration-tests"}) public void testProcessWhichRunsForUnitOrIntegrationTestGroups() { // some logic that should run only for unit and integration test groups }

Thomas Ferris Nicolaisen - Objectware Then the real fun begins.. Use Spring’s data factories Transaction testing Kan bygges videre på med Uendelige muligheter!

Thomas Ferris Nicolaisen - Objectware Q&A?