0
public class FlooringMasteryServiceLayerImplTest {

    private FlooringMasteryServiceLayer service;

    /*public FlooringMasteryServiceLayerImplTest() {
        ApplicationContext ctx
                = new ClassPathXmlApplicationContext("applicationContext.xml");
        service
                = ctx.getBean("serviceLayer", FlooringMasteryServiceLayer.class);
    }*/

    @BeforeClass
    public static void setUpClass() {
    }

    @AfterClass
    public static void tearDownClass() {
    }

    @Before
    public void setUp() {
    }

    @After
    public void tearDown() {
    }

    
    @Test
    public void testCreatedOrderFileNameFromDate() {
        
        LocalDate date = LocalDate.parse("2020-11-25");
        
        String orderFileName = service.createOrderFileNameFromDate(date);
        
        assertEquals(orderFileName, "Orders_11252020.txt", "The order file name generated was incorrect.");
    }

}

I can't seem to find what the solution is for this Failed Unit Test. I have @BeforeClass so I believe it is running JUnit4. It just keeps saying NullPointerException and I don't know how to solve this issue. Please help

Pavan Dittakavi
  • 3,013
  • 5
  • 27
  • 47

1 Answers1

0

You need to initialize your variable "service" inside @BeforeClass method.

HaroldSer
  • 2,025
  • 2
  • 12
  • 23