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.
Scout SDk usage in command line
Error creating bean with name '_muleSimpleRegistryBootstrap
“Step” or “Job” Scope for Spring-Batch beans?
WebSphere 8.5 - Linux OS problems in simple log output
How to get hardware device serial number with help of ip address?
Why &= operator doesn't work the same as &&
Best practices for dealing with exceptions in a synchronized block/method in Java [closed]
Container of Enums in java
Map Type , HashMap constructor [duplicate]
Applying blur using RenderScript in Android creates weird output
Convert regular date and time to Julian date and vice versa
Java NoClassDefFoundError, Not Sure What's Wrong
Not sure I am using inheritance/polymorphism issue?
Finding the Mode of Integers in an Array
How to configure embedded Tomcat integrated with Spring to listen requests to IP address, besides localhost?
Access Canvas From JFrame