This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

Bug 254989 - Create test for existing class creates uncompilable test.
Summary: Create test for existing class creates uncompilable test.
Status: RESOLVED FIXED
Alias: None
Product: java
Classification: Unclassified
Component: JUnit (show other bugs)
Version: 8.1
Hardware: PC Linux
: P3 normal (vote)
Assignee: Theofanis Oikonomou
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2015-09-04 02:25 UTC by alied
Modified: 2016-08-31 03:05 UTC (History)
0 users

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description alied 2015-09-04 02:25:15 UTC
while in Test file Test Case[1] the generated test is uncompilable. Lacks two required imports:

in test

  @Test
  public void testGetServletInfo() {
    System.out.println("getServletInfo");
    MavenPrjServlet instance = new MavenPrjServlet();
    String expResult = "";
    String result = instance.getServletInfo();
    assertEquals(expResult, result);//<- error here
    // TODO review the generated test code and remove the default call to fail.
    fail("The test case is a prototype.");//<- error here
  }
lines with assertEquals() and fail() show compilation errors due to missing imports.

The missing imports are:
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.fail;

That or update the test case to instruct the tester to fix imports.

[1]http://services.netbeans.org/synergy/client/app/#/assignment/1560/v/1
Comment 1 alied 2015-09-04 02:27:28 UTC
Product Version: NetBeans IDE Dev (Build 201509030002)
Java: 1.8.0_60; Java HotSpot(TM) 64-Bit Server VM 25.60-b23
Runtime: Java(TM) SE Runtime Environment 1.8.0_60-b27
System: Linux version 4.1.6+ running on amd64; UTF-8; en_US (nb)
User directory: /home/alied/.netbeans/dev
Cache directory: /home/alied/.cache/netbeans/dev
Comment 2 skomisa 2015-10-04 05:42:59 UTC
I am getting the same problem using NetBeans IDE 8.1 RC with Java 1.8.0_66 under Windows 7:

Product Version: NetBeans IDE 8.1 RC (Build 201510012201)
Java: 1.8.0_66-ea; Java HotSpot(TM) 64-Bit Server VM 25.66-b02
Runtime: Java(TM) SE Runtime Environment 1.8.0_66-ea-b02
System: Windows 7 version 6.1 running on amd64; Cp1252; en_US (nb)
User directory: C:\Users\JohnDoe\AppData\Roaming\NetBeans\8.1rc
Cache directory: C:\Users\JohnDoe\AppData\Local\NetBeans\Cache\8.1rc
Comment 3 IrianR 2016-08-06 07:20:33 UTC
This works for me in Build 201608050002

import static org.junit.Assert.*;

seems to have found it's way into the generated test file
Comment 4 alied 2016-08-31 03:03:38 UTC
verified in:
Product Version: NetBeans IDE Dev (Build 201608290002)
Java: 1.8.0_102; Java HotSpot(TM) 64-Bit Server VM 25.102-b14
Runtime: Java(TM) SE Runtime Environment 1.8.0_102-b14
System: Linux version 4.7.2 running on amd64; UTF-8; en_US (nb)
User directory: /home/alied/.netbeans/dev
Cache directory: /home/alied/.cache/netbeans/dev