`
george.gu
  • 浏览: 73940 次
  • 性别: Icon_minigender_1
  • 来自: 北京
社区版块
存档分类
最新评论

Testing in Java

 
阅读更多

QA is important for production. Testing is important for QA. 

Here I would like to talk about testing in Java application development. It won't refer to project process/life cycle control,  I will only talk something about automatically unit testing.

 

Test Data Design and Populate

There are always DB interaction in a Java enterprise application, in order to make sure persistence layer and business layer work well, we need to design test data.

Even in some pure java tools application, we need to design some test data to test extrime use cases.

 

You can use DBUnit or JDBC to populate and clean your test data aournd/after/during test case running. 

 

Test Case Design

System Test: Business Use Case Test

We can say test case design does really depend on your businesses use cases.  In fact, it is not enough, sometime and always, business use cases testing will always come in stage of  "Integration Test"/"System Test"/"End2End Test".

 

Unit Test

There are always JUnit test for:

  • A line of java function code
  • All blocks in a method
  • All methods in a java class
  • Interaction between java classes
  • Java classes security and instances in JVM

They are always come during development. 

 

Test Requirement birth xUnit

As I will list in this chapter, sometime how you want to test your code and which information will be used to assert valid will push you to define or find some useful tools to help your test design.

How to test private method?

Some people use "protected" keywords to replace "private".  I do not think it is a good design. If we want to define some unit test for private methods, it is better to design "white box" test cases for public functions which will invoke private functions.

Unit Test for Servlet

HttpUnit provide ServletRunner to simulate Servlet Container to test servlet without Java application server running.

Unit Test for Spring

We can use SpeingJUnit4ClassRunner to test Spring in standalone JVM.

Unit Test for EJB

There should be a EJB container to test your EJB functions. Normally you have to design your EJB client as test cases and deploy your EJB application in EJB container.

 

Unit Test for XML

Here I would like to list a third party tool: xmlunit which can be used to check XML content. For example, we can use xmlunit to compare if two XML contents same or not. 

UI Automatic Test

Most of Java Enterprise application provide user interfaces, so normally we can design some automatically test case on user interface:

 

  • Simulator user manipulate actions in GUI: input data, click some button.
  • Check expected item in UI

 

Httpunit and vmaggie (to be updated) is used in my current project for GUI automatic testing.  How to select UI automatically test tools: 1) which language for developing; 2) how the tool execution a test and if it satisfies your UI implementation...

 

Performance Test

Performance test is importance, you can enhance your prouction quality in stress testing, safety testing and you can also get bench mark to define the optimze configuraton parameters.

 

Normally performance test cases will focus on a business use case.  The test environement: hardware and software should be coherent with deployment ENV.

 

There are two kinds performance test:

 

  1. Automatically performance test: using tools Jmeter or LoadRunner to test some use case and it can be intergrated with automatically build.
  2. Some mannually bench mark test: optimize functiona or define benchmark for configurations. It can also use some tools in automaticaly test to prepare test data and launch testing.

 

 

分享到:
评论

相关推荐

    Pragmatic Unit Testing in Java 8 with JUnit(PACKT,2015)

    Pragmatic Unit Testing in Java 8 With JUnit steps you through all the important unit testing topics. If you've never written a unit test, you'll see screen shots from Eclipse, IntelliJ IDEA, and ...

    Pragmatic Unit Testing in Java with JUnit源码

    《Pragmatic Unit Testing in Java with JUnit》是一本专注于Java单元测试实践的书籍,其配套源代码提供了丰富的示例和实践案例,帮助读者深入理解如何有效地使用JUnit进行单元测试。JUnit是Java领域最广泛使用的...

    Pragmatic Unit Testing In Java With Junit

    ### Pragmatic Unit Testing in Java with JUnit:深入解析与实战指南 #### 一、单元测试基础概述 《Pragmatic Unit Testing in Java with JUnit》这本书为读者提供了全面而实用的单元测试指南,适用于Java开发...

    pragmatic unit testing in java with junit

    《Pragmatic Unit Testing in Java with JUnit》是一本专注于Java单元测试的指南,它深入讲解了如何有效地利用JUnit框架进行测试驱动开发(TDD)。JUnit是Java领域中最广泛使用的单元测试框架,它为开发者提供了编写...

    Pragmatic Unit Testing in Java 8 with JUnit 无水印pdf

    Pragmatic Unit Testing in Java 8 with JUnit 英文无水印pdf pdf所有页面使用FoxitReader和PDF-XChangeViewer测试都可以打开 本资源转载自网络,如有侵权,请联系上传者或csdn删除 本资源转载自网络,如有...

    Pragmatic Unit Testing in Java 8 with JUnit epub

    Pragmatic Unit Testing in Java 8 with JUnit 英文epub 本资源转载自网络,如有侵权,请联系上传者或csdn删除 本资源转载自网络,如有侵权,请联系上传者或csdn删除

    unit testing in java

    This is a practical introduction to using automated unit tests and the test-first approach in your day-to-day software development. The author gives clear guidance on how to make tests work for you, ...

    pragmatic programmers:pragmatic unit testing in java with junit

    《实用程序员:Java中的JUnit实用单元测试》一书由Andy Hunt和Dave Thomas撰写,是针对Java开发者关于单元测试的一部详尽指南。本书的核心在于强调了单元测试的重要性,并提供了使用JUnit进行有效单元测试的实践方法...

    JUnit设计模式分析及简化的JUnit代码.rar_JUnit_code testing in java_单元测试_设计模式

    JUnit设计模式分析及简化的JUnit代码 Junit 中的设计模式 感谢刘兵同志 (技术顾问 bliu76@yeah.net) JUnit 是一个优秀的Java 单元测试框架,由两位世界级软件大师Erich Gamma 和 Kent Beck 共同开发完 成。...

    Pragmatic Unit Testing-Java

    《Pragmatic Unit Testing in Java》是编程领域中一本经典的著作,由知名程序员Andy Hunt和Dave Thomas撰写。这本书深入探讨了单元测试的重要性和实践方法,特别是针对Java编程语言。单元测试是软件开发过程中的关键...

    testing java microservices

    Testing Java Microservices teaches you to implement unit and integration tests for microservice systems running on the JVM. You'll work with a microservice environment built using Java EE, WildFly ...

    Unit Testing Training - Java Unit Testing in Action.ppt

    Unit Testing Training - Java Unit Testing in Action.ppt 不错的单元测试ppt教程

    hands-automation-testing-java-beginners(2018)

    Learn Java programming concepts to design automation testing frameworks Java is one of the most commonly-used software languages by programmers and developers. Are you from a non-technical background ...

    Hands-On Automation Testing with Java for Beginners

    Then Hands-On Automation Testing with Java for Beginners is for you. This book provides you with efficient techniques to effectively handle Java-related automation projects. You will learn how to ...

    Watij - Web Application Testing in Java-开源

    Watij(发音为wattage)代表Java中的Web应用程序测试。 基于Watir的简单性并借助Java的强大功能,Watij通过真实的浏览器http://groups.google.com/group/watij自动执行Web应用程序的功能测试。

    javautjavaut

    【标题】:“单元测试之道Java版(Pragmatic Unit Testing in Java with JUnit)” 【描述】:本书“单元测试之道Java版”专注于讲解如何在Java开发中运用JUnit进行有效的单元测试,旨在帮助开发者理解单元测试的...

    Continuous Enterprise Development in Java

    Learn a use-case approach for developing Java enterprise applications in a continuously test-driven fashion. With this hands-on guide, authors and JBoss project leaders Andrew Lee Rubinger and Aslak ...

    testing in scala

    Testing in Scala starts with an introduction of the Scala programming language, explains why project infrastructure is critical, and provides compelling reasons to use Scala testing frameworks to not ...

Global site tag (gtag.js) - Google Analytics