7.1. Java Unit Testing¶
7.1.1. Objectives¶
Upon completion of this module, students will be able to:
Identify the basics of a java class including fields, constructors, methods, parameters, and use of the keyword this
Run a java program in eclipse
Run junit tests in eclipse, debug code, and tinker with code
Write a test class with test methods that use junit assert statements
Write junit tests that have complete code coverage
7.1.2. Introduction to Hokie Class¶
7.1.2.1. [6:07] Introduction to Hokie Class Video¶
<iframe id=”kaltura_player” src=”https://cdnapisec.kaltura.com/p/2375811/sp/237581100/embedIframeJs/uiconf_id/41950791/partner_id/2375811?iframeembed=true&playerId=kaltura_player&entry_id=1_0850nht8&flashvars[streamerType]=auto&flashvars[localizationCode]=en&flashvars[leadWithHTML5]=true&flashvars[sideBarContainer.plugin]=true&flashvars[sideBarContainer.position]=left&flashvars[sideBarContainer.clickToClose]=true&flashvars[chapters.plugin]=true&flashvars[chapters.layout]=vertical&flashvars[chapters.thumbnailRotator]=false&flashvars[streamSelector.plugin]=true&flashvars[EmbedPlayer.SpinnerTarget]=videoHolder&flashvars[dualScreen.plugin]=true&flashvars[hotspots.plugin]=1&flashvars[Kaltura.addCrossoriginToIframe]=true&&wid=1_57q5cew0” width=”560” height=”630” allowfullscreen webkitallowfullscreen mozAllowFullScreen allow=”autoplay *; fullscreen *; encrypted-media *” sandbox=”allow-forms allow-same-origin allow-scripts allow-top-navigation allow-pointer-lock allow-popups allow-modals allow-orientation-lock allow-popups-to-escape-sandbox allow-presentation allow-top-navigation-by-user-activation” frameborder=”0” title=”Kaltura Player”></iframe>
7.1.2.2. Zipped File Example¶
Download to run and explore on your own in eclipse:
TODO: fix URLS.
TODO: fix URLS.
This `link <>`_ will direct you to the steps to `download and import <>`_ previously written code into the Eclipse environment.
7.1.2.2.1. Note:¶
<TODO: CHECK ON THIS> The sample project above requires one or more of the CS 2114 Support Projects (CS2-Support, CS2DataStructuresLib, CS-GraphWindowLib).
Before using the above sample project you must
Complete the configuration steps described in the Pre-Lab part of Lab 2 Download the CS 2114 Support Projects to your machine When you complete the Pre-Lab part of Lab 2 you will be able to download the support projects via eclipse using the blue down arrow icon or using the Project Menu and selecting “Download Assignment…”
7.1.3. Checkpoint 1¶
7.1.4. Intro to Hokie Class JUnit Testing¶
7.1.4.1. [19:37] Hokie Class JUnit Testing Video¶
<iframe id=”kaltura_player” src=”https://cdnapisec.kaltura.com/p/2375811/sp/237581100/embedIframeJs/uiconf_id/41950791/partner_id/2375811?iframeembed=true&playerId=kaltura_player&entry_id=1_35cpol6i&flashvars[streamerType]=auto&flashvars[localizationCode]=en&flashvars[leadWithHTML5]=true&flashvars[sideBarContainer.plugin]=true&flashvars[sideBarContainer.position]=left&flashvars[sideBarContainer.clickToClose]=true&flashvars[chapters.plugin]=true&flashvars[chapters.layout]=vertical&flashvars[chapters.thumbnailRotator]=false&flashvars[streamSelector.plugin]=true&flashvars[EmbedPlayer.SpinnerTarget]=videoHolder&flashvars[dualScreen.plugin]=true&flashvars[hotspots.plugin]=1&flashvars[Kaltura.addCrossoriginToIframe]=true&&wid=1_m8r5pgfb” width=”560” height=”630” allowfullscreen webkitallowfullscreen mozAllowFullScreen allow=”autoplay *; fullscreen *; encrypted-media *” sandbox=”allow-forms allow-same-origin allow-scripts allow-top-navigation allow-pointer-lock allow-popups allow-modals allow-orientation-lock allow-popups-to-escape-sandbox allow-presentation allow-top-navigation-by-user-activation” frameborder=”0” title=”Kaltura Player”></iframe>
TODO: fix URLS.
7.1.5. Checkpoint 2¶
7.1.6. Review of Writing JUnit Tests with student.TestCase¶
<iframe id=”kaltura_player” src=”https://cdnapisec.kaltura.com/p/2375811/sp/237581100/embedIframeJs/uiconf_id/41950791/partner_id/2375811?iframeembed=true&playerId=kaltura_player&entry_id=1_zj2voxbz&flashvars[streamerType]=auto&flashvars[localizationCode]=en&flashvars[leadWithHTML5]=true&flashvars[sideBarContainer.plugin]=true&flashvars[sideBarContainer.position]=left&flashvars[sideBarContainer.clickToClose]=true&flashvars[chapters.plugin]=true&flashvars[chapters.layout]=vertical&flashvars[chapters.thumbnailRotator]=false&flashvars[streamSelector.plugin]=true&flashvars[EmbedPlayer.SpinnerTarget]=videoHolder&flashvars[dualScreen.plugin]=true&flashvars[hotspots.plugin]=1&flashvars[Kaltura.addCrossoriginToIframe]=true&&wid=1_jkkkycol” width=”560” height=”630” allowfullscreen webkitallowfullscreen mozAllowFullScreen allow=”autoplay *; fullscreen *; encrypted-media *” sandbox=”allow-forms allow-same-origin allow-scripts allow-top-navigation allow-pointer-lock allow-popups allow-modals allow-orientation-lock allow-popups-to-escape-sandbox allow-presentation allow-top-navigation-by-user-activation” frameborder=”0” title=”Kaltura Player”></iframe>
7.1.6.1. Course reference for Junit Tests:¶
TODO: fix URLS.