TEXTBOOK< Unit Test using JUnit in Eclipse >Code AAv-QT/NS/HDCV/FSOFTI dịch - TEXTBOOK< Unit Test using JUnit in Eclipse >Code AAv-QT/NS/HDCV/FSOFTI Việt làm thế nào để nói

TEXTBOOK< Unit Test using JUnit in







TEXTBOOK
< Unit Test using JUnit in Eclipse >



Code AAv-QT/NS/HDCV/FSOFT
Issue/revision 1/0
Effective date 13/09/2010













TABLE OF CONTENTS
1 INTRODUCTION 3
1.1 Purpose 3
1.2 Recommended Users 3
1.3 Definitions, Acronyms, and Abbreviations 3
1.4 Overview 3
2 OVERALL DESCRIPTION 3
3 SPECIFIC TRAINING 3
3.1 TeSt CODE COVERAGE 3
3.1.1 Java code coverage reports in Eclipse 3
3.1.2 Execute test 4
3.2 Excution Unit TeSt 6
3.2.1 Introduction 6
3.2.2 JUnit with Eclipse 7
3.2.3 JUnit (more) in Detail 13



1 INTRODUCTION
1.1 Purpose
This document provides a unit test structure overview of the MOCK project, using some technical & tools to execute unit test in the system.
1.2 Recommended Users
Fresher pass technical training
1.3 Definitions, Acronyms, and Abbreviations
N/A
1.4 Overview
This document helps the beginner specially looking for a generic approach. There are also some methods which are described bellow, and making it dynamically which is really handy for maintenance in case of frequent source code change. It includes following two parts :
1. Test code coverage
2. Execute unit test

2 OVERALL DESCRIPTION

3 SPECIFIC TRAINING
3.1 TeSt CODE COVERAGE
This part describes the Code coverage in Eclipse using EclEmma software.
3.1.1 Java code coverage reports in Eclipse
A part of our team’s “definition of done” is having unit-tests in place and, unofficially, a minimum of 80% code coverage. A Java code coverage plug-in for Eclipse : EclEmma. As you can see from its name, it’s based on the EMMA Java code coverage tool. Here’s a list with its main features :
• a coverage mode in which applications launched or unit tests are instrumented and measured
• coverage overview : a coverage view containing a report on the source code coverage values at project-level, package-level and class-level
• source highlighting in the Java code editor using customizable colors
• customizable coverage counters
• multiple coverage sessions and session merging
• importing EMMA coverage data files
• exporting to EMMA coverage data, XML and HTML
The easiest way to install it is through the update site : http://update.eclemma.org. After the installation, you will notice a new launch mode appearing in the Eclipse toolbar, called Coverage, similar to the Run and Debug modes. This new mode allows you to run coverage reports on applications or unit-tests just like you would before run those applications or unit-tests.
In a project I’m currently working on, our server-side unit tests are written using TestNG. From Eclipse, I can run one or multiple TestNG units using the Eclipse TestNG plug-in, so I can easily verify that my code passes the unit tests. I have defined a launch configuration for each server-side project which runs all of the unit-tests. To check out the code coverage for those tests, all I have to do is create a coverage configuration and make sure that I select the source code folders to be instrumented.
3.1.2 Execute test
Created a sample Java-Maven-TestNG project and added to it a simple class called ShoppingCartImpl along with a TestNG test class. Here’s how it looks :

As you can see, this is a very basic class. Now on to configuring the coverage settings ; this is a simple matter of clicking on the Coverage button in Eclipse’s toolbar and selecting the menu option Coverage Configurations…. This opens up the coverage configuration window, as seen below :

Select the TestNG test suite that you want to run and check the source folders that are relevant to code coverage. Using Maven and all source code is in src/main/java so you only select that folder. Click Apply and then you can finally run the coverage report. Click on the Coverage button and theTestNG configuration is executed and the coverage report is available :

In the bottom of the Eclipse window, you get a clear picture of the code coverage. As you can see, the are reports at project, package and class level, which also show up in the package explorer, in the left. To enable the decorators in the package explorer, go to the Eclipse menu and select Preferences -> General -> Appearance -> Label decorations, then make sure that the Java Code Coverage label decoration option is checked.
Another interesting feature of EclEmma is that after the code coverage instrumentation you can actually see the coverage in the source code. As you can see, each line relevant to the coverage report is marked with a color. Green is for 100% branch coverage, yellow is for some branch coverage and red for no coverage at all. The shopping cart has quite a low code coverage so you did shape it up. After a bit of fiddling with the code, you get a 100% code coverage and a very nice report :

3.2 Excution Unit TeSt
This part describes the execution unit test in Eclipse using JUnit.
3.2.1 Introduction
a) Unit Testing
A unit test is a piece of code written by a developer that tests a specific functiona
0/5000
Từ: -
Sang: -
Kết quả (Việt) 1: [Sao chép]
Sao chép!
SÁCH GIÁO KHOA< Đơn vị thử nghiệm sử dụng JUnit trong Eclipse >Mã AAv-QT/NS/HDCV/FSOFTVấn đề-phiên bản 1/0Hiệu quả ngày 13/09/2010 BẢNG NỘI DUNG1 GIỚI THIỆU 31.1 mục đích 31.2 khuyến cáo người dùng 31.3 định nghĩa, từ viết tắt và từ viết tắt 31.4 Các tổng quan 32 MÔ TẢ TỔNG THỂ 3ĐÀO TẠO CỤ THỂ 3 33.1 kiểm tra mã bảo hiểm 33.1.1 Java mã bảo hiểm báo cáo trong Eclipse 33.1.2 thực hiện thử nghiệm 43.2 thử nghiệm đơn vị thềEcung 63.2.1 giới thiệu 63.2.2 JUnit với Eclipse 73.2.3 JUnit (more) trong chi tiết 13 1 GIỚI THIỆU1.1 mục đíchTài liệu này cung cấp cho một đơn vị kiểm tra tổng quan về cấu trúc của mô hình dự án, bằng cách sử dụng một số kỹ thuật & công cụ để thực hiện các thử nghiệm đơn vị trong hệ thống.1.2 khuyến cáo người dùngTươi vượt qua đào tạo kỹ thuật1.3 định nghĩa, từ viết tắt và từ viết tắtN/A1.4 tổng quan vềTài liệu này giúp người mới bắt đầu tìm kiếm đặc biệt cho một cách tiếp cận chung. Cũng có một số phương pháp đó mô tả dưới đây, và làm cho nó tự động mà là thực sự tiện dụng để bảo trì trong trường hợp thay đổi mã nguồn thường xuyên. Nó bao gồm hai phần sau đây:1. kiểm tra mã bảo hiểm2. thực hiện các thử nghiệm đơn vị2 MÔ TẢ TỔNG THỂĐÀO TẠO CỤ THỂ 33.1 kiểm tra mã bảo hiểmPhần này mô tả các bảo hiểm mã trong Eclipse sử dụng phần mềm EclEmma.3.1.1 Java mã bảo hiểm báo cáo trong EclipseMột phần của nhóm của chúng tôi "định nghĩa về thực hiện" là có xét nghiệm đơn vị ở nơi, và không chính thức, tối thiểu 80% mã bao phủ. Một phạm vi bảo hiểm mã Java plug-in cho Eclipse: EclEmma. Như bạn có thể nhìn thấy từ tên gọi của nó, nó được dựa trên công cụ phạm vi bảo hiểm mã EMMA Java. Dưới đây là một danh sách với các tính năng chính:• chế độ bảo hiểm trong các ứng dụng mà đưa ra hoặc xét nghiệm đơn vị là instrumented và đo• Tổng quan về phạm vi bảo hiểm: bảo hiểm xem có chứa một báo cáo về giá trị bảo hiểm mã nguồn dự án cấp độ, gói cấp và cấp lớp• nguồn nêu bật trong trình soạn thảo mã Java bằng cách sử dụng tùy biến màu sắc• bảo hiểm tùy chỉnh đồng hồ• nhiều phạm vi bảo hiểm buổi và các phiên giao dịch sát nhập• nhập khẩu các tập tin dữ liệu bảo hiểm EMMA• xuất khẩu dữ liệu bảo hiểm EMMA, XML và HTMLCách dễ nhất để cài đặt nó là thông qua các trang web cập nhật lúc: http://update.eclemma.org. Sau khi cài đặt, bạn sẽ thấy một chế độ khởi động mới xuất hiện trong thanh công cụ của Eclipse, được gọi là bảo hiểm, tương tự như chế độ chạy và gỡ lỗi. Chế độ mới này cho phép bạn chạy các phạm vi bảo hiểm báo cáo về ứng dụng hoặc xét nghiệm đơn vị cũng giống như bạn sẽ trước khi chạy những ứng dụng hay xét nghiệm đơn vị.Trong một dự án tôi hiện đang làm việc trên, xét nghiệm đơn vị phía máy chủ của chúng tôi được viết bằng cách sử dụng TestNG. Từ Eclipse, tôi có thể chạy một hoặc nhiều đơn vị TestNG sử dụng TestNG Eclipse plug-in, vì vậy tôi có thể dễ dàng có thể xác minh rằng mã của tôi đi xét nghiệm đơn vị. Tôi đã định nghĩa một cấu hình khởi động cho từng dự án phía máy chủ mà chạy tất cả các xét nghiệm đơn vị. Để kiểm tra mã số phạm vi bảo hiểm cho những thử nghiệm này, tất cả tôi phải làm là tạo một cấu hình phạm vi bảo hiểm và đảm bảo rằng tôi chọn thư mục mã nguồn sẽ được instrumented.3.1.2 thực hiện thử nghiệmTạo ra một mẫu dự án Java-Maven-TestNG và thêm vào đó một lớp đơn giản được gọi là ShoppingCartImpl cùng với một lớp học thử nghiệm TestNG. Dưới đây là nó trông như thế nào: Như bạn thấy, đây là một lớp học rất cơ bản. Bây giờ trên để định cấu hình cài đặt phạm vi bảo hiểm; đây là một vấn đề đơn giản của cách nhấn vào nút bảo hiểm trong thanh công cụ của Eclipse và chọn tùy chọn trình đơn cấu hình bảo hiểm... Điều này mở ra cửa sổ cấu hình bảo hiểm, như nhìn thấy dưới đây: Chọn TestNG thử nghiệm mật mà bạn muốn chạy và kiểm tra các thư mục nguồn có liên quan đến mã số phạm vi bảo hiểm. Sử dụng Maven và mã nguồn tất cả là trong src/main/java vì vậy bạn chỉ chọn thư mục đó. Bấm vào áp dụng và sau đó bạn cuối cùng có thể chạy báo cáo bảo hiểm. Bấm vào cấu hình nút và theTestNG bảo hiểm được thực hiện và báo cáo bảo hiểm có sẵn: In the bottom of the Eclipse window, you get a clear picture of the code coverage. As you can see, the are reports at project, package and class level, which also show up in the package explorer, in the left. To enable the decorators in the package explorer, go to the Eclipse menu and select Preferences -> General -> Appearance -> Label decorations, then make sure that the Java Code Coverage label decoration option is checked.Another interesting feature of EclEmma is that after the code coverage instrumentation you can actually see the coverage in the source code. As you can see, each line relevant to the coverage report is marked with a color. Green is for 100% branch coverage, yellow is for some branch coverage and red for no coverage at all. The shopping cart has quite a low code coverage so you did shape it up. After a bit of fiddling with the code, you get a 100% code coverage and a very nice report : 3.2 Excution Unit TeSt This part describes the execution unit test in Eclipse using JUnit.3.2.1 Introduction a) Unit TestingA unit test is a piece of code written by a developer that tests a specific functiona
đang được dịch, vui lòng đợi..
 
Các ngôn ngữ khác
Hỗ trợ công cụ dịch thuật: Albania, Amharic, Anh, Armenia, Azerbaijan, Ba Lan, Ba Tư, Bantu, Basque, Belarus, Bengal, Bosnia, Bulgaria, Bồ Đào Nha, Catalan, Cebuano, Chichewa, Corsi, Creole (Haiti), Croatia, Do Thái, Estonia, Filipino, Frisia, Gael Scotland, Galicia, George, Gujarat, Hausa, Hawaii, Hindi, Hmong, Hungary, Hy Lạp, Hà Lan, Hà Lan (Nam Phi), Hàn, Iceland, Igbo, Ireland, Java, Kannada, Kazakh, Khmer, Kinyarwanda, Klingon, Kurd, Kyrgyz, Latinh, Latvia, Litva, Luxembourg, Lào, Macedonia, Malagasy, Malayalam, Malta, Maori, Marathi, Myanmar, Mã Lai, Mông Cổ, Na Uy, Nepal, Nga, Nhật, Odia (Oriya), Pashto, Pháp, Phát hiện ngôn ngữ, Phần Lan, Punjab, Quốc tế ngữ, Rumani, Samoa, Serbia, Sesotho, Shona, Sindhi, Sinhala, Slovak, Slovenia, Somali, Sunda, Swahili, Séc, Tajik, Tamil, Tatar, Telugu, Thái, Thổ Nhĩ Kỳ, Thụy Điển, Tiếng Indonesia, Tiếng Ý, Trung, Trung (Phồn thể), Turkmen, Tây Ban Nha, Ukraina, Urdu, Uyghur, Uzbek, Việt, Xứ Wales, Yiddish, Yoruba, Zulu, Đan Mạch, Đức, Ả Rập, dịch ngôn ngữ.

Copyright ©2024 I Love Translation. All reserved.

E-mail: