SlideShare una empresa de Scribd logo
1 de 17
Junit and Cactus

Dr. Himanshu Hora
SRMS College of Engineering & Technology
Bareilly (INDIA)
Table of Contents








Overview
Article Outline
Thesis
JUnit Background
Cactus Background
Pitfalls 1-6
Conclusion
Overview
 Junit and Cactus are popular tools for automating






testing of Java classes and web-based components
Automation accomplished using ANT (Java Make utility)
and often tested every time project built
These tools enable testers to “verify” the code is written
correctly – it was built right
Automated tests are very useful to show code works
correctly esp. after refactoring which is central to XP
I picked this article because deals with JUnit & Cactus,
offers a critique of the tools, and was practical, not just
theoretical
As this article describes, the tests themselves must be
built right in order to validate the code being tested
Outline
 Theme: Risk when testing with JUnit & Cactus
 Risk 1: No assert
 Risk 2: Unreasonable assert
 Risk 3: Console-Based Testing
 Risk 4: Unfocused Test Method
 Risk 5: Failure To Isolate Each Test
 Risk 6: Failure to Isolate Subject
Analysis
 Thesis: critique was correct but wordy, repetive, and






incomplete – missing some bigger pitfalls
Risk 1-3 are all the same – use assert correctly
Risk 4 is programming rule – write focused method
Risk 5 is JUnit rule – Use setUp and tearDown
Risk 6 is incomplete analysis of Cactus vs MockObj
Overview of Junit and Cactus, then discuss pitfalls, and
finally look at unmentioned pitfalls & issues
JUnit Overview
 Popular and simple Java framework / library for









automating testing
Integrates well with ANT – Java Make utility
General idea: write one test class per testee
Write one method to verify each main feature
Test class must extend TestCase and each test method
must start with “test”
Order of test method execution varies
Use assertTrue() and assertEquals() to verify code
Use setUp() & tearDown() prepare testcase testfixture
JUnit code example
Following test cases test the collection methods, isEmpty() and add()
import junit.framework.*;
public class SimpleTest extends TestCase {
private java.uti.Collection collection;
protected void setUp() { collection = new ArrayList(); } //
instantiates collection test fixture
protected void tearDown() { collection.clear(); }
public void testEmptyCollection() {
assertTrue(collection.isEmpty());
}
public void testOneItemCollection() {
collection.add("itemA");
assertEquals(1, collection.size());
}
}
Cactus Overview
 Built on Junit framework
 Intended to test JSP, Servlets, EJBs, Filters, and custom

tags
 Complex architecture that has client JVM call the J2EE
application server JVM via redirector
 Testcase classes must reside on client and server
 Adds two methods to Junit architecture, beginXX() and
endXX() which get called on client, rest on server
Cactus System Diagram
Cactus Sequence Diagram

– Jakarta website
Risk 1-3 – No assert, Unreasonable assert,
Console-Based Testing
 Risk 1-3 are all the same – use assert correctly
 Very important and author points out a major guideline
 test what is written in the javadocs for the testee
 implies javadocs must be up-to-date with requirements

 Author also points out to write a test case if encounter a

defect before it is corrected
 However, using assertTrue() and assertEquals() is
obvious
 These are the prominent features of the JUnit
Risk 4 – Unfocused Test Methods
 Writing focused tests is really just writing good code
 General rule of programming to make methods succinct,

this applies equally to test methods
 Writing focused test methods is the whole point
Risk 5 – Failure To Isolate Each
Test

Risk 5 is really saying to use setUp() and tearDown() to prepare/release test
fixture, an obvious suggestion – example from JUnit site
Bigger pitfall is automating creation of the test fixture in distributed
environments
import junit.framework.*;
public class SimpleTest extends TestCase {
private java.uti.Collection collection;
protected void setUp() { collection = new ArrayList(); } // instantiates
collection test fixture for 2 tests
protected void tearDown() { collection.clear(); }
public void testEmptyCollection() {
assertTrue(collection.isEmpty());
}
public void testOneItemCollection() {
collection.add("itemA");
assertEquals(1, collection.size());
}
}
Risk 6 – Failure to Isolate Subject
 Author points out one drawback of Cactus is that does

not isolate test case as MockObjects does
 MockObjects simulates the Servlet container
 Mock Object framework does isolate test but at big expense

 Massive amount of stubs needed, more code to maintain

 While Cactus may be better than MockObjects, it may

NOT be better than HttpUnit, why not compare these?
Alternative tools
 HttpUnit cleaner, simpler tool than Cactus
 HttpUnit is black box testing by calling webserver
 Test code resides ONLY on client JVM

 Various interfaces like JWebUnit (Java API) and





WebTest (XML) integrate well with ANT
Use Junit for unit tests and HttpUnit for functional
Features to analyze HTML, ie. table element tests
Features to input HTML form elements
http://www.junit.org/news/extension/index.htm
Conclusion
 Article lists some useful guidelines & pitfalls in an wordy fashion
 Many pitfalls were obvious and important ones not mentioned
 Important pitfalls not mentioned include







Cost, complexity, difficulty of distributed tests not mentioned
Performs white box tests, yet, JUnit already does this
Does not test HTTP interface (tests presentation layer poorly)
Test code must reside in same package as testee & both JVMs
Testers must be programmers
JWebUnit & WebTest better for web unit testing

 At times unclear when addressing Junit vs. Cactus and unnecessarily
complex coding examples
 However, automating testing can save time and money in the long run
 These tools, while not perfect, are major players for automated Java
testing and can verify functionality during development and refactoring
THANK YOU
Dr. Himanshu Hora
SRMS College of Engineering & Technology
Bareilly (INDIA)

Más contenido relacionado

La actualidad más candente

Boosting Approach to Solving Machine Learning Problems
Boosting Approach to Solving Machine Learning ProblemsBoosting Approach to Solving Machine Learning Problems
Boosting Approach to Solving Machine Learning ProblemsDr Sulaimon Afolabi
 
Processor allocation in Distributed Systems
Processor allocation in Distributed SystemsProcessor allocation in Distributed Systems
Processor allocation in Distributed SystemsRitu Ranjan Shrivastwa
 
Machine learning ppt.
Machine learning ppt.Machine learning ppt.
Machine learning ppt.ASHOK KUMAR
 
Swarm intelligence
Swarm intelligenceSwarm intelligence
Swarm intelligenceSophia
 
Lecture 2 role of algorithms in computing
Lecture 2   role of algorithms in computingLecture 2   role of algorithms in computing
Lecture 2 role of algorithms in computingjayavignesh86
 
Neural Networks for Pattern Recognition
Neural Networks for Pattern RecognitionNeural Networks for Pattern Recognition
Neural Networks for Pattern RecognitionVipra Singh
 
Advanced Operating System- Introduction
Advanced Operating System- IntroductionAdvanced Operating System- Introduction
Advanced Operating System- IntroductionDebasis Das
 
Microkernel architecture
Microkernel architecture Microkernel architecture
Microkernel architecture RQK Khan
 
User Interface Analysis and Design
User Interface Analysis and DesignUser Interface Analysis and Design
User Interface Analysis and Design Saqib Raza
 
REAL TIME OPERATING SYSTEM PART 1
REAL TIME OPERATING SYSTEM PART 1REAL TIME OPERATING SYSTEM PART 1
REAL TIME OPERATING SYSTEM PART 1Embeddedcraft Craft
 
Centralized shared memory architectures
Centralized shared memory architecturesCentralized shared memory architectures
Centralized shared memory architecturesGokuldhev mony
 

La actualidad más candente (20)

Boosting Approach to Solving Machine Learning Problems
Boosting Approach to Solving Machine Learning ProblemsBoosting Approach to Solving Machine Learning Problems
Boosting Approach to Solving Machine Learning Problems
 
Processor allocation in Distributed Systems
Processor allocation in Distributed SystemsProcessor allocation in Distributed Systems
Processor allocation in Distributed Systems
 
SWARM INTELLIGENCE
SWARM INTELLIGENCESWARM INTELLIGENCE
SWARM INTELLIGENCE
 
Daa unit 1
Daa unit 1Daa unit 1
Daa unit 1
 
Machine learning ppt.
Machine learning ppt.Machine learning ppt.
Machine learning ppt.
 
Soft computing
Soft computing Soft computing
Soft computing
 
Swarm intelligence
Swarm intelligenceSwarm intelligence
Swarm intelligence
 
Lecture 2 role of algorithms in computing
Lecture 2   role of algorithms in computingLecture 2   role of algorithms in computing
Lecture 2 role of algorithms in computing
 
Neural Networks for Pattern Recognition
Neural Networks for Pattern RecognitionNeural Networks for Pattern Recognition
Neural Networks for Pattern Recognition
 
Advanced Operating System- Introduction
Advanced Operating System- IntroductionAdvanced Operating System- Introduction
Advanced Operating System- Introduction
 
Basics of Soft Computing
Basics of Soft  Computing Basics of Soft  Computing
Basics of Soft Computing
 
Microkernel architecture
Microkernel architecture Microkernel architecture
Microkernel architecture
 
User Interface Analysis and Design
User Interface Analysis and DesignUser Interface Analysis and Design
User Interface Analysis and Design
 
REAL TIME OPERATING SYSTEM PART 1
REAL TIME OPERATING SYSTEM PART 1REAL TIME OPERATING SYSTEM PART 1
REAL TIME OPERATING SYSTEM PART 1
 
Distributed computing
Distributed computingDistributed computing
Distributed computing
 
convex hull
convex hullconvex hull
convex hull
 
RTOS Basic Concepts
RTOS Basic ConceptsRTOS Basic Concepts
RTOS Basic Concepts
 
Analysis of algorithm
Analysis of algorithmAnalysis of algorithm
Analysis of algorithm
 
Measures of query cost
Measures of query costMeasures of query cost
Measures of query cost
 
Centralized shared memory architectures
Centralized shared memory architecturesCentralized shared memory architectures
Centralized shared memory architectures
 

Similar a Junit and cactus

Testing Options in Java
Testing Options in JavaTesting Options in Java
Testing Options in JavaMichael Fons
 
Unit testing php-unit - phing - selenium_v2
Unit testing   php-unit - phing - selenium_v2Unit testing   php-unit - phing - selenium_v2
Unit testing php-unit - phing - selenium_v2Tricode (part of Dept)
 
J unit presentation
J unit presentationJ unit presentation
J unit presentationPriya Sharma
 
Google test training
Google test trainingGoogle test training
Google test trainingThierry Gayet
 
Junit4&testng presentation
Junit4&testng presentationJunit4&testng presentation
Junit4&testng presentationSanjib Dhar
 
SE2018_Lec 20_ Test-Driven Development (TDD)
SE2018_Lec 20_ Test-Driven Development (TDD)SE2018_Lec 20_ Test-Driven Development (TDD)
SE2018_Lec 20_ Test-Driven Development (TDD)Amr E. Mohamed
 
Testes? Mas isso não aumenta o tempo de projecto? Não quero...
Testes? Mas isso não aumenta o tempo de projecto? Não quero...Testes? Mas isso não aumenta o tempo de projecto? Não quero...
Testes? Mas isso não aumenta o tempo de projecto? Não quero...Comunidade NetPonto
 
SE2_Lec 21_ TDD and Junit
SE2_Lec 21_ TDD and JunitSE2_Lec 21_ TDD and Junit
SE2_Lec 21_ TDD and JunitAmr E. Mohamed
 
Assessing Unit Test Quality
Assessing Unit Test QualityAssessing Unit Test Quality
Assessing Unit Test Qualityguest268ee8
 
JUnit- A Unit Testing Framework
JUnit- A Unit Testing FrameworkJUnit- A Unit Testing Framework
JUnit- A Unit Testing FrameworkOnkar Deshpande
 
New and improved: Coming changes to the unittest module
 	 New and improved: Coming changes to the unittest module 	 New and improved: Coming changes to the unittest module
New and improved: Coming changes to the unittest modulePyCon Italia
 
Introduction to JUnit testing in OpenDaylight
Introduction to JUnit testing in OpenDaylightIntroduction to JUnit testing in OpenDaylight
Introduction to JUnit testing in OpenDaylightOpenDaylight
 
Test driven development and unit testing with examples in C++
Test driven development and unit testing with examples in C++Test driven development and unit testing with examples in C++
Test driven development and unit testing with examples in C++Hong Le Van
 
Unit Testing in Flutter - From Workflow Essentials to Complex Scenarios
Unit Testing in Flutter - From Workflow Essentials to Complex ScenariosUnit Testing in Flutter - From Workflow Essentials to Complex Scenarios
Unit Testing in Flutter - From Workflow Essentials to Complex ScenariosFlutter Agency
 
Apache Ant
Apache AntApache Ant
Apache AntAli Bahu
 

Similar a Junit and cactus (20)

Test Driven Development
Test Driven DevelopmentTest Driven Development
Test Driven Development
 
Testing Options in Java
Testing Options in JavaTesting Options in Java
Testing Options in Java
 
Unit Testing in Java
Unit Testing in JavaUnit Testing in Java
Unit Testing in Java
 
Unit testing php-unit - phing - selenium_v2
Unit testing   php-unit - phing - selenium_v2Unit testing   php-unit - phing - selenium_v2
Unit testing php-unit - phing - selenium_v2
 
8-testing.pptx
8-testing.pptx8-testing.pptx
8-testing.pptx
 
J unit presentation
J unit presentationJ unit presentation
J unit presentation
 
JUnit Presentation
JUnit PresentationJUnit Presentation
JUnit Presentation
 
Junit_.pptx
Junit_.pptxJunit_.pptx
Junit_.pptx
 
Google test training
Google test trainingGoogle test training
Google test training
 
Junit4&testng presentation
Junit4&testng presentationJunit4&testng presentation
Junit4&testng presentation
 
SE2018_Lec 20_ Test-Driven Development (TDD)
SE2018_Lec 20_ Test-Driven Development (TDD)SE2018_Lec 20_ Test-Driven Development (TDD)
SE2018_Lec 20_ Test-Driven Development (TDD)
 
Testes? Mas isso não aumenta o tempo de projecto? Não quero...
Testes? Mas isso não aumenta o tempo de projecto? Não quero...Testes? Mas isso não aumenta o tempo de projecto? Não quero...
Testes? Mas isso não aumenta o tempo de projecto? Não quero...
 
SE2_Lec 21_ TDD and Junit
SE2_Lec 21_ TDD and JunitSE2_Lec 21_ TDD and Junit
SE2_Lec 21_ TDD and Junit
 
Assessing Unit Test Quality
Assessing Unit Test QualityAssessing Unit Test Quality
Assessing Unit Test Quality
 
JUnit- A Unit Testing Framework
JUnit- A Unit Testing FrameworkJUnit- A Unit Testing Framework
JUnit- A Unit Testing Framework
 
New and improved: Coming changes to the unittest module
 	 New and improved: Coming changes to the unittest module 	 New and improved: Coming changes to the unittest module
New and improved: Coming changes to the unittest module
 
Introduction to JUnit testing in OpenDaylight
Introduction to JUnit testing in OpenDaylightIntroduction to JUnit testing in OpenDaylight
Introduction to JUnit testing in OpenDaylight
 
Test driven development and unit testing with examples in C++
Test driven development and unit testing with examples in C++Test driven development and unit testing with examples in C++
Test driven development and unit testing with examples in C++
 
Unit Testing in Flutter - From Workflow Essentials to Complex Scenarios
Unit Testing in Flutter - From Workflow Essentials to Complex ScenariosUnit Testing in Flutter - From Workflow Essentials to Complex Scenarios
Unit Testing in Flutter - From Workflow Essentials to Complex Scenarios
 
Apache Ant
Apache AntApache Ant
Apache Ant
 

Más de Himanshu

Structural patterns
Structural patternsStructural patterns
Structural patternsHimanshu
 
Software product line
Software product lineSoftware product line
Software product lineHimanshu
 
Shared information systems
Shared information systemsShared information systems
Shared information systemsHimanshu
 
Design Pattern
Design PatternDesign Pattern
Design PatternHimanshu
 
Creational pattern
Creational patternCreational pattern
Creational patternHimanshu
 
Architecture Review
Architecture ReviewArchitecture Review
Architecture ReviewHimanshu
 
Reliability and its principals
Reliability and its principalsReliability and its principals
Reliability and its principalsHimanshu
 
Structural and functional testing
Structural and functional testingStructural and functional testing
Structural and functional testingHimanshu
 
White box black box & gray box testing
White box black box & gray box testingWhite box black box & gray box testing
White box black box & gray box testingHimanshu
 
Pareto analysis
Pareto analysisPareto analysis
Pareto analysisHimanshu
 
Load runner & win runner
Load runner & win runnerLoad runner & win runner
Load runner & win runnerHimanshu
 
Crud and jad
Crud and jadCrud and jad
Crud and jadHimanshu
 
Risk based testing and random testing
Risk based testing and random testingRisk based testing and random testing
Risk based testing and random testingHimanshu
 
Testing a data warehouses
Testing a data warehousesTesting a data warehouses
Testing a data warehousesHimanshu
 
Software testing tools and its taxonomy
Software testing tools and its taxonomySoftware testing tools and its taxonomy
Software testing tools and its taxonomyHimanshu
 
Software reliability engineering process
Software reliability engineering processSoftware reliability engineering process
Software reliability engineering processHimanshu
 
Software reliability growth model
Software reliability growth modelSoftware reliability growth model
Software reliability growth modelHimanshu
 
Software reliability tools and common software errors
Software reliability tools and common software errorsSoftware reliability tools and common software errors
Software reliability tools and common software errorsHimanshu
 
Regression and performance testing
Regression and performance testingRegression and performance testing
Regression and performance testingHimanshu
 

Más de Himanshu (20)

Structural patterns
Structural patternsStructural patterns
Structural patterns
 
Software product line
Software product lineSoftware product line
Software product line
 
Shared information systems
Shared information systemsShared information systems
Shared information systems
 
Saam
SaamSaam
Saam
 
Design Pattern
Design PatternDesign Pattern
Design Pattern
 
Creational pattern
Creational patternCreational pattern
Creational pattern
 
Architecture Review
Architecture ReviewArchitecture Review
Architecture Review
 
Reliability and its principals
Reliability and its principalsReliability and its principals
Reliability and its principals
 
Structural and functional testing
Structural and functional testingStructural and functional testing
Structural and functional testing
 
White box black box & gray box testing
White box black box & gray box testingWhite box black box & gray box testing
White box black box & gray box testing
 
Pareto analysis
Pareto analysisPareto analysis
Pareto analysis
 
Load runner & win runner
Load runner & win runnerLoad runner & win runner
Load runner & win runner
 
Crud and jad
Crud and jadCrud and jad
Crud and jad
 
Risk based testing and random testing
Risk based testing and random testingRisk based testing and random testing
Risk based testing and random testing
 
Testing a data warehouses
Testing a data warehousesTesting a data warehouses
Testing a data warehouses
 
Software testing tools and its taxonomy
Software testing tools and its taxonomySoftware testing tools and its taxonomy
Software testing tools and its taxonomy
 
Software reliability engineering process
Software reliability engineering processSoftware reliability engineering process
Software reliability engineering process
 
Software reliability growth model
Software reliability growth modelSoftware reliability growth model
Software reliability growth model
 
Software reliability tools and common software errors
Software reliability tools and common software errorsSoftware reliability tools and common software errors
Software reliability tools and common software errors
 
Regression and performance testing
Regression and performance testingRegression and performance testing
Regression and performance testing
 

Último

TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc
 
What is Artificial Intelligence?????????
What is Artificial Intelligence?????????What is Artificial Intelligence?????????
What is Artificial Intelligence?????????blackmambaettijean
 
"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr BaganFwdays
 
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024Lorenzo Miniero
 
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptxThe Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptxLoriGlavin3
 
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek SchlawackFwdays
 
Advanced Computer Architecture – An Introduction
Advanced Computer Architecture – An IntroductionAdvanced Computer Architecture – An Introduction
Advanced Computer Architecture – An IntroductionDilum Bandara
 
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptxPasskey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptxLoriGlavin3
 
Digital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptxDigital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptxLoriGlavin3
 
"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii SoldatenkoFwdays
 
The Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsThe Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsPixlogix Infotech
 
What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024Stephanie Beckett
 
Gen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfGen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfAddepto
 
How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.Curtis Poe
 
TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024Lonnie McRorey
 
The State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptxThe State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptxLoriGlavin3
 
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024BookNet Canada
 
Moving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdfMoving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdfLoriGlavin3
 
DevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenDevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenHervé Boutemy
 
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxMerck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxLoriGlavin3
 

Último (20)

TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
 
What is Artificial Intelligence?????????
What is Artificial Intelligence?????????What is Artificial Intelligence?????????
What is Artificial Intelligence?????????
 
"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan
 
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024
 
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptxThe Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
 
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
 
Advanced Computer Architecture – An Introduction
Advanced Computer Architecture – An IntroductionAdvanced Computer Architecture – An Introduction
Advanced Computer Architecture – An Introduction
 
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptxPasskey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptx
 
Digital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptxDigital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptx
 
"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko
 
The Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsThe Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and Cons
 
What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024
 
Gen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfGen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdf
 
How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.
 
TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024
 
The State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptxThe State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptx
 
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
 
Moving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdfMoving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdf
 
DevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenDevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache Maven
 
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxMerck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
 

Junit and cactus

  • 1. Junit and Cactus Dr. Himanshu Hora SRMS College of Engineering & Technology Bareilly (INDIA)
  • 2. Table of Contents        Overview Article Outline Thesis JUnit Background Cactus Background Pitfalls 1-6 Conclusion
  • 3. Overview  Junit and Cactus are popular tools for automating      testing of Java classes and web-based components Automation accomplished using ANT (Java Make utility) and often tested every time project built These tools enable testers to “verify” the code is written correctly – it was built right Automated tests are very useful to show code works correctly esp. after refactoring which is central to XP I picked this article because deals with JUnit & Cactus, offers a critique of the tools, and was practical, not just theoretical As this article describes, the tests themselves must be built right in order to validate the code being tested
  • 4. Outline  Theme: Risk when testing with JUnit & Cactus  Risk 1: No assert  Risk 2: Unreasonable assert  Risk 3: Console-Based Testing  Risk 4: Unfocused Test Method  Risk 5: Failure To Isolate Each Test  Risk 6: Failure to Isolate Subject
  • 5. Analysis  Thesis: critique was correct but wordy, repetive, and      incomplete – missing some bigger pitfalls Risk 1-3 are all the same – use assert correctly Risk 4 is programming rule – write focused method Risk 5 is JUnit rule – Use setUp and tearDown Risk 6 is incomplete analysis of Cactus vs MockObj Overview of Junit and Cactus, then discuss pitfalls, and finally look at unmentioned pitfalls & issues
  • 6. JUnit Overview  Popular and simple Java framework / library for        automating testing Integrates well with ANT – Java Make utility General idea: write one test class per testee Write one method to verify each main feature Test class must extend TestCase and each test method must start with “test” Order of test method execution varies Use assertTrue() and assertEquals() to verify code Use setUp() & tearDown() prepare testcase testfixture
  • 7. JUnit code example Following test cases test the collection methods, isEmpty() and add() import junit.framework.*; public class SimpleTest extends TestCase { private java.uti.Collection collection; protected void setUp() { collection = new ArrayList(); } // instantiates collection test fixture protected void tearDown() { collection.clear(); } public void testEmptyCollection() { assertTrue(collection.isEmpty()); } public void testOneItemCollection() { collection.add("itemA"); assertEquals(1, collection.size()); } }
  • 8. Cactus Overview  Built on Junit framework  Intended to test JSP, Servlets, EJBs, Filters, and custom tags  Complex architecture that has client JVM call the J2EE application server JVM via redirector  Testcase classes must reside on client and server  Adds two methods to Junit architecture, beginXX() and endXX() which get called on client, rest on server
  • 10. Cactus Sequence Diagram – Jakarta website
  • 11. Risk 1-3 – No assert, Unreasonable assert, Console-Based Testing  Risk 1-3 are all the same – use assert correctly  Very important and author points out a major guideline  test what is written in the javadocs for the testee  implies javadocs must be up-to-date with requirements  Author also points out to write a test case if encounter a defect before it is corrected  However, using assertTrue() and assertEquals() is obvious  These are the prominent features of the JUnit
  • 12. Risk 4 – Unfocused Test Methods  Writing focused tests is really just writing good code  General rule of programming to make methods succinct, this applies equally to test methods  Writing focused test methods is the whole point
  • 13. Risk 5 – Failure To Isolate Each Test Risk 5 is really saying to use setUp() and tearDown() to prepare/release test fixture, an obvious suggestion – example from JUnit site Bigger pitfall is automating creation of the test fixture in distributed environments import junit.framework.*; public class SimpleTest extends TestCase { private java.uti.Collection collection; protected void setUp() { collection = new ArrayList(); } // instantiates collection test fixture for 2 tests protected void tearDown() { collection.clear(); } public void testEmptyCollection() { assertTrue(collection.isEmpty()); } public void testOneItemCollection() { collection.add("itemA"); assertEquals(1, collection.size()); } }
  • 14. Risk 6 – Failure to Isolate Subject  Author points out one drawback of Cactus is that does not isolate test case as MockObjects does  MockObjects simulates the Servlet container  Mock Object framework does isolate test but at big expense  Massive amount of stubs needed, more code to maintain  While Cactus may be better than MockObjects, it may NOT be better than HttpUnit, why not compare these?
  • 15. Alternative tools  HttpUnit cleaner, simpler tool than Cactus  HttpUnit is black box testing by calling webserver  Test code resides ONLY on client JVM  Various interfaces like JWebUnit (Java API) and     WebTest (XML) integrate well with ANT Use Junit for unit tests and HttpUnit for functional Features to analyze HTML, ie. table element tests Features to input HTML form elements http://www.junit.org/news/extension/index.htm
  • 16. Conclusion  Article lists some useful guidelines & pitfalls in an wordy fashion  Many pitfalls were obvious and important ones not mentioned  Important pitfalls not mentioned include       Cost, complexity, difficulty of distributed tests not mentioned Performs white box tests, yet, JUnit already does this Does not test HTTP interface (tests presentation layer poorly) Test code must reside in same package as testee & both JVMs Testers must be programmers JWebUnit & WebTest better for web unit testing  At times unclear when addressing Junit vs. Cactus and unnecessarily complex coding examples  However, automating testing can save time and money in the long run  These tools, while not perfect, are major players for automated Java testing and can verify functionality during development and refactoring
  • 17. THANK YOU Dr. Himanshu Hora SRMS College of Engineering & Technology Bareilly (INDIA)