Can I do a jUnit Test in the Same Class as My Main Code?
I am new to jUnit and I am finding testing the small project I'm working on difficult. All the examples for jUnit testing seem to involve math, and what I wrote is a simple application that takes information via Scanner and creates various objects and stores them in an ArrayList. One of my thoughts was to test if the ArrayList was empty, but I obviously cannot access it from a separate class, but the standard seems to be to separate the test from the code. So I am not sure what to do?
You could provide a protected accessor for the array so that it can be used by the unit tests (which should be in the same package).
The typical well established practices are: Unit test and production code goes into different files living in different projects but using the same package names. Unit tests should not rely on internal state of production code. You don't want to write a test that needs to know about a field within the class under test. Because that means that your test can break when you change the production code to solve the problem differently. The real answer here: you should share pieces of your code with us, to receive really helpful feedback.
“Block” ArrayList size
In a construct of the following if - else if - else if structure, how many comparisons are made, 1 or 3?
Replacing all special characters, numbers and alphabets
SINGLE_TABLE inheritance strategy discriminating based on parent table
Android studio error RuntimeException: Unclosed ': Unclosed '
How to point to jdk1.8 in eclipse juno?
Get list of all files in a directory inside assets
Using Ember with Spring.io Framework. Doable or a bad idea? [closed]
VLCJ Can' t open audio streaming using http on client-side
Convert matlab to java
log4j2 loging database varchar2 error
Store date in class
Set the image duration with jcodec in android
Stuck with Java Generic Classes
Java SSO with using waffle in Tomcat