Welcome to the CSC Q&A, where you can get help (and share your knowledge) about computer science!

How can we access a field, to use in the test class?

+2 votes
asked Oct 10 in CSC 285 (F17) by Faisal Nawaz (1,856 points)

2 Answers

+1 vote
It depends on what class you are testing. But fields are usually accessed through "getter" methods. In each of our test classes we have been creating new player and inventory objects and manipulating those while testing effects and conditions.
answered Oct 10 by Samuel Totten (1,988 points)
0 votes
Getters if the variables are private, object.field if it is public. If you are referring to how to create an object in a tester you will need to import the class such as: import edu.augustana.csc285.game.datamodel.Inventory;

Also keep in mind that all instances of the object are removed from method to method since the JUnit tests calls one method at a time instead of like a regular class.
answered Oct 11 by Daniel Zwiener (6,896 points)
...