Unit is a simple framework to write repeatable tests. It is an instance of the xunit architecture for unit testing frameworks.
Annotation @Test @Test(timeout=ms) @Test(expected=class) @Ignore Explanation Written for the test method. When timeout paramater exists, the test would fail if the test takes longer than defined time. When expected parameter exists, the test would fail if the test doesn t make defined exception. If you want to see the report but test code is not implemented yet, you can use this annotation. @After @Before @AfterClass @BeforeClass It s same as setup() and teardown() in JUnit3. It is executed before and after each test methods. It s same as setupbeforeclass() and teardownafterclass() in JUnit3. It is executed before and after the class.
Annotation @RunWith(value=class) @SuiteClasses(value={clas ses}) @Parameters Explanation It is used to decide test runner. It is used to define tests which would be included in test suites. It is used for multiple tests for several parameters.
Method Explanation assertequals (expected type, result type) assertequals (expected object, result object) assertsame (expected object, result object) After comparing expected value with result value, returns success if those are same. After comparing expected object s value with result object s value, returns success if those are same. After comparing expected object s memory address and result object s memory address, returns success if those are same. assertnull(object) assertnotnull(object) asserttrue(boolean) assertfalse(boolean) After testing object is null or not, returns success if object is null. After testing object is null or not, returns success if object is not null. After condition is true or not, returns success if condition is true. After condition is true, or not returns success if condition is false.
- Set up the environmental variable -tells the location of the installed JDK
- Set up the path variable to help to find the executable file like java.exe for other tools.
- http://www.eclipse.org/downloads/
- right click your project-[preferences]-[java Build Path] -[Add External JARs ]
Keyboard shortcut Ctrl+Space Ctrl+Shift+O Ctrl+I Ctrl+Shift+/ Explaination Auto complete Auto import the library Auto indent Making blocked lines comments
IDE / Build tool Main/Initial Author Available from SCM-Manager SCM-Manager Plugin Page jgrasp Larry Barowski jgrasp Home Page Sonar Freddy Mallet (initial author) Sonar Home Page Eclipse/RAD/RDz David Schneider Eclipse-CS Home Page Eclipse/RAD/RDz Roman Ivanov Project Page Eclipse/RAD/RDz Marco van Meegen Checklipse Home Page IntelliJ IDEA Jakub Slawinski QAPlug IntelliJ IDEA James Shiell Checkstyle-idea Project Page IntelliJ IDEA Mark Lussier JetStyle Project Page NetBeans Petr Hejl Checkstyle Beans NetBeans Paul Goulbourn nbcheckstyle NetBeans Software Quality Environment (SQE) jcoderz fawkez BlueJ Rick Giles bluejcheckstyle home page tide Built in Emacs JDE Markus Mohnen Part of the standard JDEE distribution jedit Todd Papaioannou JEdit CheckStylePlugin Vim editor Xandy Johnson Plugin Homepage Maven Vincent Massol Checkstyle supported out of the box QALab Benoit Xhenseval QALab Home Page
항목원인회피방법 JavadocPackage 모든 method, class 에는 help 가존재해야한다. 시간상힘들고, 관리되지않는주석은더욱큰혼란 을가지고온다. method 의이름규칙으로대신하기 로한다. NewlineAtEndOfFile Translation java code의가장마지막줄은빈공백열로마쳐져야한다. Properties file을이용한경우, 국가별번역이모두존재해야한다. 마지막 line 에는항시빈공백을넣는다. 국가별번역파일을따로맊들거나 default 문자열맊 을이용한다. FileLength java file 의 length 는 2000 line 을넘지않도록작성한다. 2000 line 이넘어가는경우, 설계상의문제가있기때문 에 class 를재정의한다. FileTabCharacter RegexpSingleline java file 내부에 tab 문자열이있으면앆된다. 1 line에는한개의method맊이존재해야한다. tab 을모두 space 로치환해서사용하도록한다. 1 line 에대한설정을명확하게해서사용하도록한다.
Side Good Bad points You can use PMD without Eclipse! There re several report formats like html,xml,test Very detailed! You can check CPD function! PMD doesn t support UI like findbugs. Tooooooo detailed!
Class directory Reference library Source directory
?
Side Good points Bad Findbugs takes longer time than PMD Reports only XML format
- SonarQube s numerous dashboards offer quick insight. - SonarQube is an open platform to manage code quality. As such, it covers the 7 axes of code quality: - SonarQube s numerous dashboards offer quick insight. - Several methods are available to replay the past, showing how your metrics evolved.
- Install Sonar plugin in Eclipse [Help]-[Install new software ] http://dist.sonar-ide.codehaus.org/eclipse/
- Download SonarQube http://www.sonarqube.org/ Download latest version(3.7.4) unzip the file - Download SonarQube Runner http://www.sonarqube.org/ Download latest version(2.3) unzip the file
- Connect to SonarQube server : [Window]- [preferences]-[sonarqube ]-[servers] [test connection]
- When you connect to SonarQube server -Open SonarQube server before connecting! - C:\...\sonar-3.7.4\sonar-3.7.4\bin\windows-x86-xx \StartSonar.bat - If you didn t open the Server
name of your project directory do not use \!!!! use / - C:\sonarqube\sonar-runner-dist-2.3\sonar-runner- 2.3\conf\sonar-runner.properties Edit the file!!!
- C:\sonarqube\sonar-runner-dist-2.3\sonar-runner-2.3\bin - Execute sonar-runner
- open your browser and access to http://localhost:9000 Login with ID : admin / PW : admin - It would be closer to red when there s many error.
- Dashboard shows the result in terms of 7 standards of quality. - potential bugs - coding rule - test - duplication - comments - architecture and design - complexity
- Dashboard (with plugin example)
- Code comment
one of your sonarqube server cannot be reached. please check your connection settings. authentication error The folder C:devworkspaceHell osrc does not exist for Hello 서버가열리지않아서생기는에러 StartSonar.bat 으로서버실행 이클립스 windows-preferences 에서 ID/pw 가일치하지않으면나는에러서버로그인후 admin/admin 으로로그인 Sonar-runner.properties 수정시 \ 가아닌 / 로경로설정
- SonarQube 의장점 - dashboard 가항목별로정리되어있어이해하고알아보기쉬움 - 다른 plugin 을추가설치한다면더욱맋은분석결과를확인할수있음 - 또한코드별로코멘트를달아팀원별로의견공유를할수있음 - SonarQube 의단점 -eclipse 내에서분석결과를확인할수있는것이아니라따로인터넷페이지에서확인해야함 -server 를켜놓고 cmd 창에서 runner 를돌려야하는점때문에불편함 - 어려웠던점및소감 - 설치의어려움
G o o d B a d Checkstyle PMD FindBugs SONAR - 지속적으로업데이트 -Code convention 을지키게끔연습하는데가장유용. - 한글로된자료가맋음 - 진짜버그는못찾을수도있음 (code convention 을준수했나를가장중점적으로보는툴!) - 엄청나게꼼꼼 - 분석에오랜시간이소요되지않음 -CPD 분석기능제공 - 여러가지리포트포맷을제공 - 툴이조금무거욲편 - 자체 UI 를제공하지않아이클립스없이쓰려면힘들다 - 쓰면서가장에러가맋이난툴. - 툴이가벼움 - 자체 UI 제공으로사용이편리 - 잠재적버그를찾는데가장유용 - 바이트코드분석으로호출되지않는영역에러찾음 - 툴이가벼움에도불구하고분석에 PMD 보다오랜시간이소요됨 - 리포트포맷이다양하지않음 - 오라클,MySQL 같은 DB 와연동가능 - 복잡도분석같은다른툴에는없는기능제공 - 일자별로변동을파악가능 - 인스톨어려움 - 서버가항상틀어져있어야함. - 이클립스가아닌웹상에서확인해야함.
http://cafe.naver.com/tbed/16 http://stackoverflow.com/questions/16778062/ importing-rules-for-pmd-eclipse http://cafe.naver.com/tbed/16 http://www.swbank.kr/html/tools/toolsfile /PMD_05_functionIntro.pdf
http://findbugs.sourceforge.net/manual/gui.html http://en.wikipedia.org/wiki/findbugs http://stackoverflow.com/questions/6395546 /findbugs-not-showing-the-bugs-found
http://www.sonarqube.org/ http://www.slideshare.net/allnewangel/sonar-23151331 http://dryang.egloos.com/viewer/4005366