Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

Java

"There is a compiler error" and i feel i got a working way -Unit Testing in Java - Testing the Running Total

I am doing the final challenge and after working a bit and scanning through the coding i thought i have found a possible working way, here is my code:

@Test
public void vendingOperationSuccessfulWithIncrementedSalesTotal() throws Exception {
    machine.addMoney(75);

    Item item = machine.vend("A1");

    assertEquals("Twinkies", item.getName());

  assertEquals(75, machine.getRunningSalesTotal());
}

And this is the Preview:

./com/teamtreehouse/vending/VendingMachineTest.java:10: error: expected private getRunningSalesTotal{ ^ ./com/teamtreehouse/vending/VendingMachineTest.java:11: error: illegal start of type return runningSalesTotal; ^ ./com/teamtreehouse/vending/VendingMachineTest.java:23: error: class, interface, or enum expected public void setUp() throws Exception { ^ ./com/teamtreehouse/vending/VendingMachineTest.java:25: error: class, interface, or enum expected machine = new VendingMachine(notifier, 10, 10, 10); ^ ./com/teamtreehouse/vending/VendingMachineTest.java:26: error: class, interface, or enum expected machine.restock("A1", "Twinkies", 10, 30, 75); ^ ./com/teamtreehouse/vending/VendingMachineTest.java:27: error: class, interface, or enum expected } ^ ./com/teamtreehouse/vending/VendingMachineTest.java:30: error: class, interface, or enum expected public void vendingOperationSuccessfulWithIncrementedSalesTotal() throws Exception { ^ ./com/teamtreehouse/vending/VendingMachineTest.java:33: error: class, interface, or enum expected Item item = machine.vend("A1"); ^ ./com/teamtreehouse/vending/VendingMachineTest.java:35: error: class, interface, or enum expected assertEquals("Twinkies", item.getName()); ^ ./com/teamtreehouse/vending/VendingMachineTest.java:37: error: class, interface, or enum expected assertEquals(75, machine.getRunningSalesTotal()); ^ ./com/teamtreehouse/vending/VendingMachineTest.java:38: error: class, interface, or enum expected } ^ ./com/teamtreehouse/vending/VendingMachineTest.java:14: error: class NotifierSub is public, should be declared in a file named NotifierSub.java public class NotifierSub implements Notifier { ^ ./com/teamtreehouse/vending/VendingMachineTest.java:10: error: cannot find symbol private getRunningSalesTotal{ ^ symbol: class getRunningSalesTotal location: class VendingMachineTest 13 errors

Any idea what i am doing wrong?

1 Answer

Never mind I found out what i was doing wrong. I had manage to delete one of the other tests without realizing it.