Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Lab 1 added files #31

Open
wants to merge 19 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -29,3 +29,4 @@
# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
hs_err_pid*
/.metadata/
HelloWorld/.settings/org.eclipse.core.resources.prefs
190 changes: 95 additions & 95 deletions Circles/Readme
Original file line number Diff line number Diff line change
@@ -1,95 +1,95 @@

CS 371 Assignment: Junit
========================

This assignment involves using JUnit to perform automated
unit testing on some classes.

JUnit is available at www.junit.org.

Select "Download and Install" and follow the "Plain-old JAR" commands.
You need junit-4.12.jar and hamcrest-core-1.3.jar. Do not grab anything
related to "Maven". Do NOT put the jarfiles in your CS371 workspace and
definitely do NOT commit them into the course repository! I do not want
35 copies of JUnit jarfiles in the repository! Place them elsewhere and
then set your classpath. There are two scripts that show examples of
setting your classpath (or you can set it on your Java command line with
-cp). Learning to use your classpath is part of learning Java.

From the JUnit home page, click on "Getting Started" in the upper right,
and read the short "JUnit Cookbook" to see a short introduction. The
Javadoc-generated API documentation is also useful. You can find many
other resources and tutorials on the web that describe JUnit. As part of
this assignment you must generate the Javadoc files in a subdirectory named
"apidoc" and it must include documentation for all class members, including
private members (you need to figure out how to do these things; it's easy).

If you have set your classpath, you should be able to compile and run the
example test in the directory: see the file "run-test" to see an example
of how the Junit tests are run (this can also be done in a Java main,
which is in the Circle1Test.java code, but is commented out).

Your task for this assignment is to create unit tests which accomplish
certain goals, mainly ensuring good testing coverage of the classes under
test, for one particular type of testing.

You have three classes to test: an abstract class Circle and two
subclasses, Circle1 and Circle2. The requirements for all three are in
Javadoc-able comments in the Circle class. All three classes may have
errors; as you encounter errors, you MUST document the error, including
which test found the error, and then you must fix the error. There is also
a "CircleRun" class which demonstrates some example execution, but your
unit tests using JUnit will exercise an object (or more) of the class(es)
directly, and will not use the CircleRun class. You do not have to test
this class, it is there just so that you can run the classes in a
standalone matter to see what they do.

When creating test cases you should not have "redundant" test cases which
do not exercise anything new. Having more tests than you need will REDUCE
your grade, not enhance it!

You must write a comment header for each test case that succinctly describes
that test case. Just write a short description -- a long verbose description
is no good!

This assignment: Closed Box Testing
==================================

Closed box testing aims to test the code according to its requirements,
without being able to look into the code and see how things are implemented.
The code is treated as a "closed box" -- in the case of testing an individual
class, only its public API is considered.

Suggested reading:

textbook, section 8.2 (p410 in particular)
http://en.wikipedia.org/wiki/Black_box_testing
http://en.wikipedia.org/wiki/Equivalence_Partitioning
http://en.wikipedia.org/wiki/Boundary-value_analysis

Use the ideas from equivalence partitioning and boundary value analysis to
create JUnit test cases which fully test the three classes under closed box
testing. The JUnit test classes must be named "Circle1Test" and
"Circle2Test". Note that since this is closed box testing and both concrete
classes under test should implement the same requirements, your two test
classes should be exactly the same except for which class they reference
(Circle1 and Circle2).

Submitting the assignment
=========================

To submit this assignment, upload a zip file of a
directory named "assignment-junit1" containing the following:

1. Your java source files for Circle1Test and Circle2Test including all the
test cases you created (they should contain the same exact tests).
2. The possibly updated Java source files for Circle, Circle1, and Circle2.
3. The documentation generated by JavaDoc (as described above; normally it
is not appropriate to commit auto-generated files into a repository, but
this assignment is an exception.)
4. Your plain text file that documents any errors you found, which test cases
found them, and how you fixed them.

Do NOT commit any .class files, nor any libraries.


CS 371 Assignment: Junit
========================
This assignment involves using JUnit to perform automated
unit testing on some classes.
JUnit is available at www.junit.org.
Select "Download and Install" and follow the "Plain-old JAR" commands.
You need junit-4.12.jar and hamcrest-core-1.3.jar. Do not grab anything
related to "Maven". Do NOT put the jarfiles in your CS371 workspace and
definitely do NOT commit them into the course repository! I do not want
35 copies of JUnit jarfiles in the repository! Place them elsewhere and
then set your classpath. There are two scripts that show examples of
setting your classpath (or you can set it on your Java command line with
-cp). Learning to use your classpath is part of learning Java.
From the JUnit home page, click on "Getting Started" in the upper right,
and read the short "JUnit Cookbook" to see a short introduction. The
Javadoc-generated API documentation is also useful. You can find many
other resources and tutorials on the web that describe JUnit. As part of
this assignment you must generate the Javadoc files in a subdirectory named
"apidoc" and it must include documentation for all class members, including
private members (you need to figure out how to do these things; it's easy).
If you have set your classpath, you should be able to compile and run the
example test in the directory: see the file "run-test" to see an example
of how the Junit tests are run (this can also be done in a Java main,
which is in the Circle1Test.java code, but is commented out).
Your task for this assignment is to create unit tests which accomplish
certain goals, mainly ensuring good testing coverage of the classes under
test, for one particular type of testing.
You have three classes to test: an abstract class Circle and two
subclasses, Circle1 and Circle2. The requirements for all three are in
Javadoc-able comments in the Circle class. All three classes may have
errors; as you encounter errors, you MUST document the error, including
which test found the error, and then you must fix the error. There is also
a "CircleRun" class which demonstrates some example execution, but your
unit tests using JUnit will exercise an object (or more) of the class(es)
directly, and will not use the CircleRun class. You do not have to test
this class, it is there just so that you can run the classes in a
standalone matter to see what they do.
When creating test cases you should not have "redundant" test cases which
do not exercise anything new. Having more tests than you need will REDUCE
your grade, not enhance it!
You must write a comment header for each test case that succinctly describes
that test case. Just write a short description -- a long verbose description
is no good!
This assignment: Closed Box Testing
==================================
Closed box testing aims to test the code according to its requirements,
without being able to look into the code and see how things are implemented.
The code is treated as a "closed box" -- in the case of testing an individual
class, only its public API is considered.
Suggested reading:
textbook, section 8.2 (p410 in particular)
http://en.wikipedia.org/wiki/Black_box_testing
http://en.wikipedia.org/wiki/Equivalence_Partitioning
http://en.wikipedia.org/wiki/Boundary-value_analysis
Use the ideas from equivalence partitioning and boundary value analysis to
create JUnit test cases which fully test the three classes under closed box
testing. The JUnit test classes must be named "Circle1Test" and
"Circle2Test". Note that since this is closed box testing and both concrete
classes under test should implement the same requirements, your two test
classes should be exactly the same except for which class they reference
(Circle1 and Circle2).
Submitting the assignment
=========================
To submit this assignment, upload a zip file of a
directory named "assignment-junit1" containing the following:
1. Your java source files for Circle1Test and Circle2Test including all the
test cases you created (they should contain the same exact tests).
2. The possibly updated Java source files for Circle, Circle1, and Circle2.
3. The documentation generated by JavaDoc (as described above; normally it
is not appropriate to commit auto-generated files into a repository, but
this assignment is an exception.)
4. Your plain text file that documents any errors you found, which test cases
found them, and how you fixed them.
Do NOT commit any .class files, nor any libraries.
Binary file added Circles/bin/edu/nmsu/cs/circles/Circle.class
Binary file not shown.
Binary file added Circles/bin/edu/nmsu/cs/circles/Circle1.class
Binary file not shown.
Binary file added Circles/bin/edu/nmsu/cs/circles/Circle1Test.class
Binary file not shown.
Binary file added Circles/bin/edu/nmsu/cs/circles/Circle2.class
Binary file not shown.
Binary file added Circles/bin/edu/nmsu/cs/circles/Circle2Test.class
Binary file not shown.
Binary file added Circles/bin/edu/nmsu/cs/circles/CircleRun.class
Binary file not shown.
Binary file added Circles/bin/edu/nmsu/cs/circles/Point.class
Binary file not shown.
60 changes: 60 additions & 0 deletions Circles/build.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
<project name="Circles" default="run" basedir=".">

<property name="src-dir" location="src/"/>
<property name="build-dir" location="bin/"/>
<property name="junit-dir" location="lib/"/>

<target name="compile">
<mkdir dir="${build-dir}"/>
<javac srcdir="${src-dir}" includeantruntime="false" debug="true" destdir="${build-dir}">
<classpath>
<fileset dir="${junit-dir}">
<include name="**/*.jar"/>
</fileset>
</classpath>
</javac>


</target>

<target name="run" depends="clean,compile">
<java classname="edu.nmsu.cs.circles.CircleRun" classpath="${build-dir}" fork="true" dir="${basedir}">
<arg value="2"/>
<arg value="4"/>
<arg value="6"/>
<arg value="8"/>
<arg value="10"/>
<arg value="12"/>
</java>
</target>

<target name="testCircle1" depends="clean,compile">
<java classname="org.junit.runner.JUnitCore" fork="true" dir="${basedir}">
<classpath>
<fileset dir="${junit-dir}">
<include name="**/*.jar"/>
</fileset>
<pathelement path="${build-dir}"/>
</classpath>
<arg value="edu.nmsu.cs.circles.Circle1Test"/>
</java>
</target>

<target name="testCircle2" depends="clean,compile">
<java classname="org.junit.runner.JUnitCore" fork="true" dir="${basedir}">
<classpath>
<fileset dir="${junit-dir}">
<include name="**/*.jar"/>
</fileset>
<pathelement path="${build-dir}"/>
</classpath>
<arg value="edu.nmsu.cs.circles.Circle2Test"/>
</java>
</target>

<target name="test" depends="testCircle1, testCircle2"/>

<target name="clean">
<delete dir="${build-dir}"/>
</target>
</project>
Binary file added Circles/lib/hamcrest-core-2.2.jar
Binary file not shown.
Binary file added Circles/lib/junit-4.13.2.jar
Binary file not shown.
2 changes: 1 addition & 1 deletion Circles/run-test
Original file line number Diff line number Diff line change
@@ -1 +1 @@
java org.junit.runner.JUnitCore Circle1Test
java org.junit.runner.JUnitCore Circle1Test
2 changes: 1 addition & 1 deletion Circles/set-path.csh
Original file line number Diff line number Diff line change
@@ -1 +1 @@
setenv CLASSPATH .:/home/jcook/lib/junit-4.12.jar:/home/jcook/lib/hamcrest-core-1.3.jar
setenv CLASSPATH .:/home/jcook/lib/junit-4.12.jar:/home/jcook/lib/hamcrest-core-1.3.jar
2 changes: 1 addition & 1 deletion Circles/set-path.sh
Original file line number Diff line number Diff line change
@@ -1 +1 @@
export CLASSPATH=.:/home/jcook/lib/junit-4.12.jar:/home/jcook/lib/hamcrest-core-1.3.jar
export CLASSPATH=.:/home/jcook/lib/junit-4.12.jar:/home/jcook/lib/hamcrest-core-1.3.jar
Loading