SlideShare une entreprise Scribd logo
1  sur  43
Java Basic Training
     III. Maven & JUnit
Jump into Maven

•   Perfect Build

•   What is Maven

•   Core Concepts

•   Lifecycle and Plugin

•   Acknowledgement
Perfect Build
Perfect Build

• Automatic
Perfect Build

• Automatic
• Platform independent
Perfect Build

• Automatic
• Platform independent
• Bunch of reusable components
Perfect Build

• Automatic
• Platform independent
• Bunch of reusable components
• Standardized
Perfect Build

• Automatic
• Platform independent
• Bunch of reusable components
• Standardized
• Reproducible
What is Maven
• Build tool, same as make, ant


     clean   compile   ...   package   ...
Exercises


• Create a Maven based project
• Try clean, compile, package, install
What is Maven
• Dependency management tool
• With repository
                 log4j:log4j:1.2.15



c.e.m:web:7.0


                   org.apache.struts:structs-core:2.1.0


  org.springframework:spring-core:2.5
What is Maven
• Dependency management tool
• With repository

                                           log4j:log4j:1.2.15


                     Depends on   org.apache.struts:structs-core:2.1.0
    Repository
                                  org.springframework:spring-core:2.5

                                             c.e.m:web:7.0
Exercises


• Change default junit dependency to version
  4
• Add slf4j and logback as dependencies
What is Maven
• Information aggregation
Exercises


• Generate Maven site
 • as homework
What is Maven
• Set of rules - Convention over
  Configuration
What is Maven
• Set of rules - Convention over
  Configuration
 • pom.xml
What is Maven
• Set of rules - Convention over
  Configuration
 • pom.xml
 • src/main/java
 • src/main/resources
What is Maven
• Set of rules - Convention over
  Configuration
 • pom.xml
 • src/main/java
 • src/main/resources
 • src/test/java
 • src/test/resources
Core Concepts
•   Coordinate
Core Concepts
•   Coordinate
    •   groupId – derived from project name, rather than
        organization name
    •   artifactId – derived from module name, rather
        than project name
    •   version – project version
Core Concepts
•   Coordinate
    •   groupId – derived from project name, rather than
        organization name
    •   artifactId – derived from module name, rather
        than project name
    •   version – project version
    •   packaging – project packaging type, like jar
        (default)
Core Concepts
•   Coordinate
    •   groupId – derived from project name, rather than
        organization name
    •   artifactId – derived from module name, rather
        than project name
    •   version – project version
    •   packaging – project packaging type, like jar
        (default)
    •   classifier – additional artifacts, like -javadoc.jar
Core Concepts
•   Dependency

    •   GAV

    •   type

    •   scope

    •   optional

    •   exclusions
Core Concepts
•   Dependency

    •   GAV        <project>
                     …
                     <dependencies>


    •
                       <dependency>
        type             <groupId>log4j</groupId>
                         <artifactId>log4j</artifactId>
                         <version>1.2.15</version>
                       </dependency>

    •   scope
                       <dependency>
                         <groupId>junit</groupId>
                         <artifactId>junit</artifactId>
                         <version>3.8.1</version>


    •
                       </dependency>
        optional     </dependencies>
                     …
                   </project>



    •   exclusions
Core Concepts
•   Repository Layout

    •   GAV

•   Repository Type          upload



    •   Local

    •   Remote          download



    •   Central

•   Nexus
Core Concepts
•   Snapshot version
    •   7.0.0-SNAPSHOT
    •   7.0.0-20120214.221414-13


    •   > mvn clean install -U

    •   Update daily by default, -U to force updating


    •   Used for intermedium version
Core Concepts
 •    Snapshot version
     •   7.0.0-SNAPSHOT
                      7.0.0-pc1-SNAPSHOT


     •
                 7.0.0
         7.0.0-20120214.221414-13
                          7.0.0-pc2-SNAPSHOT



                         7.0.1-SNAPSHOT   7.0.1   7.0.2-SNAPSHOT

     •   > mvn clean install -U                    7.0.1-pc1-SNAPSHOT


     •   Update daily by default, -U to force updating
7.0.0-SNAPSHOT           7.1.0-SNAPSHOT                                 master




     •   Used for intermedium version
Lifecycle and Plugin
Lifecycle and Plugin
Plugin internal binding
Lifecycle Phase         Plugin Goal                            Task

process-resource        maven-resources-plugin:resources       copy main resources file to output dir


compile                 maven-compiler-plugin:compile          compile main java code to output dir


process-test-resource   maven-resources-plugin:testResources   copy test resource file to test output dir


test-compile            maven-compiler-plugin:testCompile      compile test java code to test output dir


test                    maven-surefire-plugin:test              run tests


package                 maven-jar-plugin:jar                   pack the jar file


install                 maven-install-plugin:install           install project output artifacts to local repo


deploy                  maven-deploy-plugin:deploy             deploy project output artifacts to remote repo
Acknowledgement
•   Most of the contents are
    from Juven's book

•   You'll have chance to go
    through the whole
    training session talking
    about Maven hold by
    Juven

           Juven Xu
          www.juvenxu.com
      juven.xu@outsofting.com
         twitter.com/juvenxu
         weibo.com/juvenxu
Acknowledgement
•   Most of the contents are
    from Juven's book

•   You'll have chance to go
    through the whole
    training session talking
    about Maven hold by
    Juven

           Juven Xu
          www.juvenxu.com
      juven.xu@outsofting.com
         twitter.com/juvenxu
         weibo.com/juvenxu
JUnit in Action

•   Why Unit Test

•   Go with Maven

•   The Calculator Case

•   Coverage

•   Guidelines
Why Unit Test




      http://www.agitar.com/solutions/why_unit_testing.html
Why Unit Test

• Be professional
• Find defects as early as possible
• Living description of how the unit works
• Insurance and confidence for refactoring
• A lot of pleasure
Go with Maven


• Hands-on
The Calculator Case

• @Before
• @Test, expected, timeout
• @BeforeClass
• @After
• @AfterClass
Coverage
Coverage
•   Coverage helps
    •   Understand unit test quality
    •   Understand Product quality

    •   Pass QD5 in /// the company
Coverage
•   Coverage helps
    •   Understand unit test quality
    •   Understand Product quality

    •   Pass QD5 in /// the company
•   Coverage types
    •   Line
    •   Branch
    •   ...
Coverage
•   Coverage helps
    •   Understand unit test quality
    •   Understand Product quality

    •   Pass QD5 in /// the company
•   Coverage types
    •   Line
    •   Branch
    •   ...
•   Coverage tools
    •   Cobertura
    •   Emma
    •   Clover (commercial)
Guidelines

•   http://geosoft.no/development/unittesting.html
    (GFWed)

•   http://www.mymindleaks.com/blog/article/junit-
    best-practices-how-to-write-good-junit-test-
    cases.html
Homework
• Convert AddressBook project to Maven
  based
• Add unit test
• Search and learn how to use Cobertura, and
  make sure unit test line coverage reaches
  85%
• Add necessary configuration and files to
  facilitate generating Maven site

Contenu connexe

Tendances

Enterprise Maven Repository BOF
Enterprise Maven Repository BOFEnterprise Maven Repository BOF
Enterprise Maven Repository BOFMax Andersen
 
Lorraine JUG (1st June, 2010) - Maven
Lorraine JUG (1st June, 2010) - MavenLorraine JUG (1st June, 2010) - Maven
Lorraine JUG (1st June, 2010) - MavenArnaud Héritier
 
Apache Maven - eXo TN presentation
Apache Maven - eXo TN presentationApache Maven - eXo TN presentation
Apache Maven - eXo TN presentationArnaud Héritier
 
Introduction to Maven
Introduction to MavenIntroduction to Maven
Introduction to MavenSperasoft
 
An introduction to Maven
An introduction to MavenAn introduction to Maven
An introduction to MavenJoao Pereira
 
Continuous Deployment Pipeline with maven
Continuous Deployment Pipeline with mavenContinuous Deployment Pipeline with maven
Continuous Deployment Pipeline with mavenAlan Parkinson
 
Introduction tomaven
Introduction tomavenIntroduction tomaven
Introduction tomavenManav Prasad
 
Gradle - Build system evolved
Gradle - Build system evolvedGradle - Build system evolved
Gradle - Build system evolvedBhagwat Kumar
 
Apache Maven for SoftServe IT Academy
Apache Maven for SoftServe IT AcademyApache Maven for SoftServe IT Academy
Apache Maven for SoftServe IT AcademyVolodymyr Ostapiv
 
JBoss Enterprise Maven Repository
JBoss Enterprise Maven RepositoryJBoss Enterprise Maven Repository
JBoss Enterprise Maven RepositoryMax Andersen
 
Gradle - time for another build
Gradle - time for another buildGradle - time for another build
Gradle - time for another buildIgor Khotin
 

Tendances (20)

Maven
Maven Maven
Maven
 
Apache Maven
Apache MavenApache Maven
Apache Maven
 
Introduction to maven
Introduction to mavenIntroduction to maven
Introduction to maven
 
Maven
MavenMaven
Maven
 
Enterprise Maven Repository BOF
Enterprise Maven Repository BOFEnterprise Maven Repository BOF
Enterprise Maven Repository BOF
 
Lorraine JUG (1st June, 2010) - Maven
Lorraine JUG (1st June, 2010) - MavenLorraine JUG (1st June, 2010) - Maven
Lorraine JUG (1st June, 2010) - Maven
 
Apache Maven - eXo TN presentation
Apache Maven - eXo TN presentationApache Maven - eXo TN presentation
Apache Maven - eXo TN presentation
 
Introduction to Maven
Introduction to MavenIntroduction to Maven
Introduction to Maven
 
Maven
MavenMaven
Maven
 
An introduction to Maven
An introduction to MavenAn introduction to Maven
An introduction to Maven
 
Maven Introduction
Maven IntroductionMaven Introduction
Maven Introduction
 
Continuous Deployment Pipeline with maven
Continuous Deployment Pipeline with mavenContinuous Deployment Pipeline with maven
Continuous Deployment Pipeline with maven
 
Maven ppt
Maven pptMaven ppt
Maven ppt
 
Introduction tomaven
Introduction tomavenIntroduction tomaven
Introduction tomaven
 
Maven advanced
Maven advancedMaven advanced
Maven advanced
 
Gradle - Build system evolved
Gradle - Build system evolvedGradle - Build system evolved
Gradle - Build system evolved
 
Apache Maven for SoftServe IT Academy
Apache Maven for SoftServe IT AcademyApache Maven for SoftServe IT Academy
Apache Maven for SoftServe IT Academy
 
JBoss Enterprise Maven Repository
JBoss Enterprise Maven RepositoryJBoss Enterprise Maven Repository
JBoss Enterprise Maven Repository
 
Maven Overview
Maven OverviewMaven Overview
Maven Overview
 
Gradle - time for another build
Gradle - time for another buildGradle - time for another build
Gradle - time for another build
 

Similaire à 4 maven junit

Introduction to Maven for beginners and DevOps
Introduction to Maven for beginners and DevOpsIntroduction to Maven for beginners and DevOps
Introduction to Maven for beginners and DevOpsSISTechnologies
 
Intelligent Projects with Maven - DevFest Istanbul
Intelligent Projects with Maven - DevFest IstanbulIntelligent Projects with Maven - DevFest Istanbul
Intelligent Projects with Maven - DevFest IstanbulMert Çalışkan
 
How maven makes your development group look like a bunch of professionals.
How maven makes your development group look like a bunch of professionals.How maven makes your development group look like a bunch of professionals.
How maven makes your development group look like a bunch of professionals.Fazreil Amreen Abdul Jalil
 
Learning Maven by Example
Learning Maven by ExampleLearning Maven by Example
Learning Maven by ExampleHsi-Kai Wang
 
Maven Basics - Explained
Maven Basics - ExplainedMaven Basics - Explained
Maven Basics - ExplainedSmita Prasad
 
BMO - Intelligent Projects with Maven
BMO - Intelligent Projects with MavenBMO - Intelligent Projects with Maven
BMO - Intelligent Projects with MavenMert Çalışkan
 
S/W Design and Modularity using Maven
S/W Design and Modularity using MavenS/W Design and Modularity using Maven
S/W Design and Modularity using MavenScheidt & Bachmann
 
(Re)-Introduction to Maven
(Re)-Introduction to Maven(Re)-Introduction to Maven
(Re)-Introduction to MavenEric Wyles
 
Developing Liferay Plugins with Maven
Developing Liferay Plugins with MavenDeveloping Liferay Plugins with Maven
Developing Liferay Plugins with MavenMika Koivisto
 
Ci jenkins maven svn
Ci jenkins maven svnCi jenkins maven svn
Ci jenkins maven svnAnkur Goyal
 
Embrace Maven
Embrace MavenEmbrace Maven
Embrace MavenGuy Marom
 
Java build tools
Java build toolsJava build tools
Java build toolsSujit Kumar
 
Java is evolving rapidly: Maven helps you staying on track
Java is evolving rapidly:  Maven helps you staying on trackJava is evolving rapidly:  Maven helps you staying on track
Java is evolving rapidly: Maven helps you staying on trackArnaud Héritier
 
Juggling Java EE with Enterprise Apache Maven
Juggling Java EE with Enterprise Apache MavenJuggling Java EE with Enterprise Apache Maven
Juggling Java EE with Enterprise Apache Mavenelliando dias
 
Introduction to maven, its configuration, lifecycle and relationship to JS world
Introduction to maven, its configuration, lifecycle and relationship to JS worldIntroduction to maven, its configuration, lifecycle and relationship to JS world
Introduction to maven, its configuration, lifecycle and relationship to JS worldDmitry Bakaleinik
 

Similaire à 4 maven junit (20)

Introduction to Maven for beginners and DevOps
Introduction to Maven for beginners and DevOpsIntroduction to Maven for beginners and DevOps
Introduction to Maven for beginners and DevOps
 
Intelligent Projects with Maven - DevFest Istanbul
Intelligent Projects with Maven - DevFest IstanbulIntelligent Projects with Maven - DevFest Istanbul
Intelligent Projects with Maven - DevFest Istanbul
 
Maven
MavenMaven
Maven
 
How maven makes your development group look like a bunch of professionals.
How maven makes your development group look like a bunch of professionals.How maven makes your development group look like a bunch of professionals.
How maven makes your development group look like a bunch of professionals.
 
Learning Maven by Example
Learning Maven by ExampleLearning Maven by Example
Learning Maven by Example
 
Intro to Maven.ppt
Intro to Maven.pptIntro to Maven.ppt
Intro to Maven.ppt
 
Maven Basics - Explained
Maven Basics - ExplainedMaven Basics - Explained
Maven Basics - Explained
 
BMO - Intelligent Projects with Maven
BMO - Intelligent Projects with MavenBMO - Intelligent Projects with Maven
BMO - Intelligent Projects with Maven
 
S/W Design and Modularity using Maven
S/W Design and Modularity using MavenS/W Design and Modularity using Maven
S/W Design and Modularity using Maven
 
Introduction to Maven
Introduction to MavenIntroduction to Maven
Introduction to Maven
 
(Re)-Introduction to Maven
(Re)-Introduction to Maven(Re)-Introduction to Maven
(Re)-Introduction to Maven
 
Developing Liferay Plugins with Maven
Developing Liferay Plugins with MavenDeveloping Liferay Plugins with Maven
Developing Liferay Plugins with Maven
 
Ci jenkins maven svn
Ci jenkins maven svnCi jenkins maven svn
Ci jenkins maven svn
 
Embrace Maven
Embrace MavenEmbrace Maven
Embrace Maven
 
Maven basic concept
Maven basic conceptMaven basic concept
Maven basic concept
 
Java build tools
Java build toolsJava build tools
Java build tools
 
Java is evolving rapidly: Maven helps you staying on track
Java is evolving rapidly:  Maven helps you staying on trackJava is evolving rapidly:  Maven helps you staying on track
Java is evolving rapidly: Maven helps you staying on track
 
Mavennotes.pdf
Mavennotes.pdfMavennotes.pdf
Mavennotes.pdf
 
Juggling Java EE with Enterprise Apache Maven
Juggling Java EE with Enterprise Apache MavenJuggling Java EE with Enterprise Apache Maven
Juggling Java EE with Enterprise Apache Maven
 
Introduction to maven, its configuration, lifecycle and relationship to JS world
Introduction to maven, its configuration, lifecycle and relationship to JS worldIntroduction to maven, its configuration, lifecycle and relationship to JS world
Introduction to maven, its configuration, lifecycle and relationship to JS world
 

Dernier

08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking MenDelhi Call girls
 
Advantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your BusinessAdvantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your BusinessPixlogix Infotech
 
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxKatpro Technologies
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountPuma Security, LLC
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptxHampshireHUG
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerThousandEyes
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Miguel Araújo
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEarley Information Science
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdfhans926745
 
What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?Antenna Manufacturer Coco
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfsudhanshuwaghmare1
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking MenDelhi Call girls
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUK Journal
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)Gabriella Davis
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxMalak Abu Hammad
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...apidays
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsJoaquim Jorge
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...Martijn de Jong
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024The Digital Insurer
 

Dernier (20)

08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
 
Advantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your BusinessAdvantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your Business
 
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path Mount
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf
 
What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptx
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024
 

4 maven junit

  • 1. Java Basic Training III. Maven & JUnit
  • 2. Jump into Maven • Perfect Build • What is Maven • Core Concepts • Lifecycle and Plugin • Acknowledgement
  • 5. Perfect Build • Automatic • Platform independent
  • 6. Perfect Build • Automatic • Platform independent • Bunch of reusable components
  • 7. Perfect Build • Automatic • Platform independent • Bunch of reusable components • Standardized
  • 8. Perfect Build • Automatic • Platform independent • Bunch of reusable components • Standardized • Reproducible
  • 9. What is Maven • Build tool, same as make, ant clean compile ... package ...
  • 10. Exercises • Create a Maven based project • Try clean, compile, package, install
  • 11. What is Maven • Dependency management tool • With repository log4j:log4j:1.2.15 c.e.m:web:7.0 org.apache.struts:structs-core:2.1.0 org.springframework:spring-core:2.5
  • 12. What is Maven • Dependency management tool • With repository log4j:log4j:1.2.15 Depends on org.apache.struts:structs-core:2.1.0 Repository org.springframework:spring-core:2.5 c.e.m:web:7.0
  • 13. Exercises • Change default junit dependency to version 4 • Add slf4j and logback as dependencies
  • 14. What is Maven • Information aggregation
  • 15. Exercises • Generate Maven site • as homework
  • 16. What is Maven • Set of rules - Convention over Configuration
  • 17. What is Maven • Set of rules - Convention over Configuration • pom.xml
  • 18. What is Maven • Set of rules - Convention over Configuration • pom.xml • src/main/java • src/main/resources
  • 19. What is Maven • Set of rules - Convention over Configuration • pom.xml • src/main/java • src/main/resources • src/test/java • src/test/resources
  • 20. Core Concepts • Coordinate
  • 21. Core Concepts • Coordinate • groupId – derived from project name, rather than organization name • artifactId – derived from module name, rather than project name • version – project version
  • 22. Core Concepts • Coordinate • groupId – derived from project name, rather than organization name • artifactId – derived from module name, rather than project name • version – project version • packaging – project packaging type, like jar (default)
  • 23. Core Concepts • Coordinate • groupId – derived from project name, rather than organization name • artifactId – derived from module name, rather than project name • version – project version • packaging – project packaging type, like jar (default) • classifier – additional artifacts, like -javadoc.jar
  • 24. Core Concepts • Dependency • GAV • type • scope • optional • exclusions
  • 25. Core Concepts • Dependency • GAV <project> … <dependencies> • <dependency> type <groupId>log4j</groupId> <artifactId>log4j</artifactId> <version>1.2.15</version> </dependency> • scope <dependency> <groupId>junit</groupId> <artifactId>junit</artifactId> <version>3.8.1</version> • </dependency> optional </dependencies> … </project> • exclusions
  • 26. Core Concepts • Repository Layout • GAV • Repository Type upload • Local • Remote download • Central • Nexus
  • 27. Core Concepts • Snapshot version • 7.0.0-SNAPSHOT • 7.0.0-20120214.221414-13 • > mvn clean install -U • Update daily by default, -U to force updating • Used for intermedium version
  • 28. Core Concepts • Snapshot version • 7.0.0-SNAPSHOT 7.0.0-pc1-SNAPSHOT • 7.0.0 7.0.0-20120214.221414-13 7.0.0-pc2-SNAPSHOT 7.0.1-SNAPSHOT 7.0.1 7.0.2-SNAPSHOT • > mvn clean install -U 7.0.1-pc1-SNAPSHOT • Update daily by default, -U to force updating 7.0.0-SNAPSHOT 7.1.0-SNAPSHOT master • Used for intermedium version
  • 30. Lifecycle and Plugin Plugin internal binding Lifecycle Phase Plugin Goal Task process-resource maven-resources-plugin:resources copy main resources file to output dir compile maven-compiler-plugin:compile compile main java code to output dir process-test-resource maven-resources-plugin:testResources copy test resource file to test output dir test-compile maven-compiler-plugin:testCompile compile test java code to test output dir test maven-surefire-plugin:test run tests package maven-jar-plugin:jar pack the jar file install maven-install-plugin:install install project output artifacts to local repo deploy maven-deploy-plugin:deploy deploy project output artifacts to remote repo
  • 31. Acknowledgement • Most of the contents are from Juven's book • You'll have chance to go through the whole training session talking about Maven hold by Juven Juven Xu www.juvenxu.com juven.xu@outsofting.com twitter.com/juvenxu weibo.com/juvenxu
  • 32. Acknowledgement • Most of the contents are from Juven's book • You'll have chance to go through the whole training session talking about Maven hold by Juven Juven Xu www.juvenxu.com juven.xu@outsofting.com twitter.com/juvenxu weibo.com/juvenxu
  • 33. JUnit in Action • Why Unit Test • Go with Maven • The Calculator Case • Coverage • Guidelines
  • 34. Why Unit Test http://www.agitar.com/solutions/why_unit_testing.html
  • 35. Why Unit Test • Be professional • Find defects as early as possible • Living description of how the unit works • Insurance and confidence for refactoring • A lot of pleasure
  • 36. Go with Maven • Hands-on
  • 37. The Calculator Case • @Before • @Test, expected, timeout • @BeforeClass • @After • @AfterClass
  • 39. Coverage • Coverage helps • Understand unit test quality • Understand Product quality • Pass QD5 in /// the company
  • 40. Coverage • Coverage helps • Understand unit test quality • Understand Product quality • Pass QD5 in /// the company • Coverage types • Line • Branch • ...
  • 41. Coverage • Coverage helps • Understand unit test quality • Understand Product quality • Pass QD5 in /// the company • Coverage types • Line • Branch • ... • Coverage tools • Cobertura • Emma • Clover (commercial)
  • 42. Guidelines • http://geosoft.no/development/unittesting.html (GFWed) • http://www.mymindleaks.com/blog/article/junit- best-practices-how-to-write-good-junit-test- cases.html
  • 43. Homework • Convert AddressBook project to Maven based • Add unit test • Search and learn how to use Cobertura, and make sure unit test line coverage reaches 85% • Add necessary configuration and files to facilitate generating Maven site

Notes de l'éditeur

  1. \n
  2. \n
  3. \n
  4. \n
  5. \n
  6. \n
  7. \n
  8. \n
  9. \n
  10. \n
  11. \n
  12. \n
  13. \n
  14. \n
  15. \n
  16. \n
  17. \n
  18. \n
  19. \n
  20. \n
  21. \n
  22. \n
  23. \n
  24. \n
  25. \n
  26. \n
  27. \n
  28. \n
  29. \n
  30. \n
  31. \n
  32. \n
  33. \n
  34. \n
  35. \n
  36. \n
  37. \n
  38. \n
  39. \n
  40. \n
  41. \n
  42. \n
  43. \n
  44. \n
  45. \n
  46. \n
  47. \n
  48. \n
  49. \n
  50. \n