For some reason, the setUp() method of my test class is not being called before my test method.
import static org.junit.jupiter.api.Assertions.*;
import org.junit.After;
import org.junit.Before;
import org.junit.jupiter.api.Test;
class BlockchainAuctionTest {
private BlockchainAuction auction;
@Before
public void setUp() {
auction = new BlockchainAuction();
System.out.println("setUp");
}
@After
public void tearDown() {
System.out.println("tearDown");
}
@Test
void testOneBid() {
Bid bid = new Bid("Bitcoin", "Devon", 1.0);
assertTrue(auction.recordNewBid(bid), "first bid should be added without error");
}
}
Specifically, I am getting a null pointer exception on the line that says
assertTrue(auction.recordNewBid(bid), "first bid should be added without error");
because auction has not been initialized. I am using Eclipse.
Aucun commentaire:
Enregistrer un commentaire