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 Unit Testing in Java How to Test Running Tests and Reading Output

Nancy Melucci
PLUS
Nancy Melucci
Courses Plus Student 36,158 Points

Compile error when trying to run JUnit test on Creditor. java

I am using a different version of IntelliJ so I am not sure I have set this up correctly. When I went to follow Craig running the first test, it recompiled the project and then threw this error...

Error:(8, 6) java: cannot find symbol symbol: class Test location: class CreditorTest

I don't know if this is enough information but if anyone in the (Tree)House has an idea of how to fix it, I would be grateful.

Thanks and hope you are having a good week out there whereever you are....

Craig Dennis
Craig Dennis
Treehouse Teacher

Hi Nancy!

Can you include your code please? We'll figure it out!

Nancy Melucci
Nancy Melucci
Courses Plus Student 36,158 Points

Ah Craig thank you. You are a mensch. I am really afraid it will be something dumb that I should have recognized immediately....here we go:

Also, I am using a different edition of IntellJ than you do in the video...I did not get some of the dialog boxes I saw you working with in the tutorial. Just in case that matters.

CreditorTest.java,

import static org.junit.Assert.*;

/**
 * Created by Nancy on 2/2/2016.
 */
public class CreditorTest {

    @Test
    public void testRefund() throws Exception {


    }

}

Main.java

package com.teamtreehouse.vending;

public class Main {

    public static void main(String[] args) {
    // write your code here
        Notifier notifier = new Notifier() {

            @Override
            public void onSale(Item item) {
                System.out.printf("Sold item %s for %s",
                        item.getName(),
                        item.getRetailPrice());
            }
        };
        VendingMachine machine = new VendingMachine(notifier, 10, 10, 10);
        try {
            System.out.println("Restocking");
            machine.restock("A1", "Twinkies", 9, 30, 75);

            System.out.println("Adding money");
            machine.addMoney(75);

            System.out.println("Vending");
            machine.vend("A1");
        } catch (InvalidLocationException ile) {
            ile.printStackTrace();
        } catch (NotEnoughFundsException nefe) {
            nefe.printStackTrace();
        }
    }
}

Creditor.java

java
package com.teamtreehouse.vending;

public class Creditor {
    private int funds;

    public Creditor() {
        funds = 0;
    }

    public void addFunds(int money) {
        funds += money;
    }

    public void deduct(int money) throws NotEnoughFundsException {
        if (money > funds) {
            throw new NotEnoughFundsException();
        }
        funds -= money;
    }

    public int refund() {
        int refund = funds;
        funds = 0;
        return refund;
    }

    public int getAvailableFunds() {
        return funds;
    }

}