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

Can I write MORE code in my JUnit test methods?

+3 votes
asked Oct 10, 2017 in CSC 285 (F17) by Forrest Stonedahl (100 points)

2 Answers

+1 vote
Sure -- they're just Java methods -- do what needs to be done!

For example, your test might:

a) create a Player object

b) create an Effect

c) apply the Effect to the Player

d) check (assert) whether the Player's inventory (or stats, or whatever) changed.
answered Oct 10, 2017 by Forrest Stonedahl (100 points)
0 votes
Just one quick note, if you want to assertEquals two object then you need to implement equal method, Eclipse has a generator for equal based on fields if you want quick cheat way of doing it.
answered Oct 10, 2017 by Dat Tran (100 points)