Our system can run over both web platform and Windows platform. We created tests for the web platform by Cucumer, Selenium, and JUnit and it works fine but very slow.
We decided to execute the same tests on the Windows platform, and created a program which integrates with it, operated by the JUnit. It works very very faster, but we have a problem.
Most cases when AssertTrue has to fail the test, it actually calls fail(), but the test continues running to the next sentence. Moreover, the output of the fail() is actually printed.
Why does it occur?
EDIT: I don't know what can be clearer than what I wrote, but you want:
assertTrue("retval = " + params[0], params[0].equals("0"));
When params[0] = "1018" the test is supposed to stop with failure. But it continues to the next code instruction.
The output is:
java.lang.AssertionError: retval = 1026
at org.junit.Assert.fail(Assert.java:88)
at org.junit.Assert.assertTrue(Assert.java:41)
at com.eshbel_17_0.WinformBridge.readToJava(WinformBridge.java:225)
at com.eshbel_17_0.WinformExec.runDirectProcedure(WinformExec.java:111)
at com.eshbel_17_0.Definitions.the_user_runs_the_direct_activation(Definitions.java:362)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at cucumber.runtime.Utils$1.call(Utils.java:34)
at cucumber.runtime.Timeout.timeout(Timeout.java:13)
at cucumber.runtime.Utils.invoke(Utils.java:30)
at cucumber.runtime.java.JavaStepDefinition.execute(JavaStepDefinition.java:35)
at cucumber.runtime.StepDefinitionMatch.runStep(StepDefinitionMatch.java:37)
at cucumber.runtime.Runtime.runStep(Runtime.java:298)
at cucumber.runtime.model.StepContainer.runStep(StepContainer.java:44)
at cucumber.runtime.model.StepContainer.runSteps(StepContainer.java:39)
at cucumber.runtime.model.CucumberScenario.run(CucumberScenario.java:48)
at cucumber.runtime.junit.ExecutionUnitRunner.run(ExecutionUnitRunner.java:91)
at cucumber.runtime.junit.FeatureRunner.runChild(FeatureRunner.java:63)
at cucumber.runtime.junit.FeatureRunner.runChild(FeatureRunner.java:18)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:238)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:63)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:236)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:53)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:229)
at org.junit.runners.ParentRunner.run(ParentRunner.java:309)
at cucumber.runtime.junit.FeatureRunner.run(FeatureRunner.java:70)
at cucumber.api.junit.Cucumber.runChild(Cucumber.java:89)
at cucumber.api.junit.Cucumber.runChild(Cucumber.java:40)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:238)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:63)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:236)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:53)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:229)
at org.junit.runners.ParentRunner.run(ParentRunner.java:309)
at cucumber.api.junit.Cucumber.run(Cucumber.java:94)
at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:50)
at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:459)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:675)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:382)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:192)
Oh, I found why it happens, and it's so foolish mistake!
This code is sorrounded by try-catch block, and gets also Throwable e. it includes also Assertion Error exception, so test not failed.
Related
I have tried below lines
#Test
public void getXYZ_Success() throws Exception {
Response result=abc.XYZ(exampleHeader);
Response response=new Response();
response.setMessage(null);
response.setStatusCode("01");
response.setStatus("Failure");
List<ExampleFilterLkp> exampleFilterList=new ArrayList<exampleFilterLkp>();
exampleFilterLkp exampleFilterLkp=new exampleFilterLkp();
examplFilterLkp.setexampleKey("1");
exampleList.add(exampleFilterLkp);
doReturn(response).when(result);
}
I'm getting below error, how to solve this issue, please help me
org.mockito.exceptions.misusing.NotAMockException:
Argument passed to when() is not a mock!
Example of correct stubbing:
doThrow(new RuntimeException()).when(mock).someMethod();
at com.firstdata.mpl.manager.exampleTest.getexampleFilter_NullFailure(FuelManagerTest.java:184)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:497)
at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:47)
at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:44)
at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:26)
at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:271)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:70)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:50)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:238)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:63)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:236)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:53)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:229)
at org.junit.runners.ParentRunner.run(ParentRunner.java:309)
at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:86)
at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:459)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:670)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:382)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:192)
Exception message says that argument passed to when() is not a mock.
In this case, it's a result
doReturn(response).when(result);
Exception message even says what a correct invocation should look like:
Example of correct stubbing:
doThrow(new RuntimeException()).when(mock).someMethod();
It isn't clear from the question what is being tested here. If abc is a mock object and you want to return the response on XYZ call then something like this should work:
doReturn(response).when(abc).XYZ(exampleHeader);
Otherwise, you need to explain what exactly are you trying to achieve.
result object is not a mock object. when needs a mock object as an arg --> when(mock)
I am trying to use Guava's collections to create a map that will store a class instance as the key and an Integer number as the value. So something like this:
Key - Value
FooOne - 1
FooTwo - 2
FooThree - 3
FooFour - 4
I have this in the code right now:
private ClassToInstanceMap<Object> classRanking = MutableClassToInstanceMap.create();
classRanking.put(FooOne.class, 0);
classRanking.put(FooTwo.class, 1);
classRanking.put(FooThree.class, 2);
classRanking.put(FooFour.class, 3);
But that throws an error when run:
java.lang.ClassCastException: Cannot cast java.lang.Integer to com.jer.abc.test.FooOne
at java.lang.Class.cast(Unknown Source)
at com.google.common.collect.MutableClassToInstanceMap.cast(MutableClassToInstanceMap.java:82)
at com.google.common.collect.MutableClassToInstanceMap.access$000(MutableClassToInstanceMap.java:36)
at com.google.common.collect.MutableClassToInstanceMap$1.checkKeyValue(MutableClassToInstanceMap.java:67)
at com.google.common.collect.MutableClassToInstanceMap$1.checkKeyValue(MutableClassToInstanceMap.java:64)
at com.google.common.collect.MapConstraints$ConstrainedMap.put(MapConstraints.java:313)
at com.fmr.gps.web.support.PortfolioInsightsSupport.populateRankingMap(PortfolioInsightsSupport.java:33)
at com.fmr.gps.web.support.PortfolioInsightsSupport.<init>(PortfolioInsightsSupport.java:29)
at com.fmr.gps.web.PortfolioInsightsSupportTest.setUp(PortfolioInsightsSupportTest.java:38)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:47)
at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:44)
at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:24)
at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:271)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:70)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:50)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:238)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:63)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:236)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:53)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:229)
at org.junit.runners.ParentRunner.run(ParentRunner.java:309)
at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:86)
at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:459)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:675)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:382)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:192)
So I was thinking about using a plain old java map but this thread tells me to do otherwise. So any ideas on how to fix this?
ClassToInstanceMap is for when you want to do stuff like classRanking.put(FooOne.class, new FooOne()), i.e. the values will be instances of the key. But 0 is not an instance of FooOne, it's just an Integer. You just want a normal Map<Class<?>, Integer>, so use a HashMap or something.
the method process is really throwing the exception however when I test this in junit is not working eventhough I placed next to the #Test annotation the expected exception to be thrown the test fails why is this happening?
java.lang.ArithmeticException: / by zero
at com.javageek.junit.Calculator.process(Calculator.java:88)
at com.javageek.junit.CalculatorTest.CalculatorTestDivisionByZero(CalculatorTest.java:50)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:47)
at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:44)
at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
at org.junit.internal.runners.statements.ExpectException.evaluate(ExpectException.java:19)
at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:271)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:70)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:50)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:238)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:63)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:236)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:53)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:229)
at org.junit.runners.ParentRunner.run(ParentRunner.java:309)
at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:50)
at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197)
#Test(expected=ArithmeticException.class)
public void CalculatorTestDivisionByZero(){
Calculator calculator = new Calculator();
calculator.process("DivisionByZero.txt");
}
You need to specify the Runner for your test class as:
#RunWith(JUnit4.class)
Plus your test function probably should not start with a capital letter (CalculatorTestDivisionByZero).
The following works for me (i.e. the test passes):
#Test(expected=ArithmeticException.class)
public void CalculatorTestDivisionByZero(){
int i = 23 / 0;
System.out.println("i=" + i);
}
I don't need lowercase methods or #RunWith.
Maybe your calculator is starting a different thread or process? Then the Exception wouldn't be thrown in the test Thread.
You could also check whether you are importing the correct ArithmeticException class, there may be other ones provided by your application.
We are trying to run a OLAP query with olap4j against SSAS. I've managed to setup the XML/A endpoint, and SSMS connects to the endpoint correctly and works fine.
However each time I try to run a query from JAVA it fails.
Class.forName("org.olap4j.driver.xmla.XmlaOlap4jDriver");
Connection connection = DriverManager.getConnection(
"jdbc:xmla:Server=http://servername/msmdpump.dll;Catalog=DatabaseName");
OlapWrapper wrapper = (OlapWrapper) connection;
OlapConnection olapConnection = wrapper.unwrap(OlapConnection.class);
CellSet set = olapConnection.createStatement().executeOlapQuery(
"SELECT [Measures].[Foo] ON COLUMNS, " +
"[Dimension].[Id].[All].children ON ROWS FROM [Cube]");
The exception/stacktrace:
java.lang.AssertionError
at org.olap4j.driver.xmla.XmlaOlap4jElement.<init>(XmlaOlap4jElement.java:43)
at org.olap4j.driver.xmla.XmlaOlap4jProperty.<init>(XmlaOlap4jProperty.java:54)
at org.olap4j.driver.xmla.XmlaOlap4jConnection$PropertyHandler.handle(XmlaOlap4jConnection.java:1890)
at org.olap4j.driver.xmla.XmlaOlap4jConnection.populateList(XmlaOlap4jConnection.java:854)
at org.olap4j.driver.xmla.DeferredNamedListImpl.populateList(DeferredNamedListImpl.java:136)
at org.olap4j.driver.xmla.DeferredNamedListImpl.getList(DeferredNamedListImpl.java:90)
at org.olap4j.driver.xmla.DeferredNamedListImpl.size(DeferredNamedListImpl.java:116)
at java.util.AbstractCollection.toArray(Unknown Source)
at java.util.ArrayList.addAll(Unknown Source)
at org.olap4j.driver.xmla.XmlaOlap4jLevel.getProperties(XmlaOlap4jLevel.java:189)
at org.olap4j.driver.xmla.XmlaOlap4jConnection$MemberHandler.addUserDefinedDimensionProperties(XmlaOlap4jConnection.java:1739)
at org.olap4j.driver.xmla.XmlaOlap4jConnection$MemberHandler.handle(XmlaOlap4jConnection.java:1698)
at org.olap4j.driver.xmla.XmlaOlap4jConnection.populateList(XmlaOlap4jConnection.java:854)
at org.olap4j.driver.xmla.XmlaOlap4jCube$RawMetadataReader.lookupMemberRelatives(XmlaOlap4jCube.java:547)
at org.olap4j.driver.xmla.XmlaOlap4jCube$RawMetadataReader.lookupMemberByUniqueName(XmlaOlap4jCube.java:438)
at org.olap4j.driver.xmla.XmlaOlap4jCube$DelegatingMetadataReader.lookupMemberByUniqueName(XmlaOlap4jCube.java:252)
at org.olap4j.driver.xmla.XmlaOlap4jCube$CachingMetadataReader.lookupMemberByUniqueName(XmlaOlap4jCube.java:338)
at org.olap4j.driver.xmla.XmlaOlap4jConnection$MeasureHandler.handle(XmlaOlap4jConnection.java:1555)
at org.olap4j.driver.xmla.XmlaOlap4jConnection.populateList(XmlaOlap4jConnection.java:854)
at org.olap4j.driver.xmla.XmlaOlap4jCube.<init>(XmlaOlap4jCube.java:110)
at org.olap4j.driver.xmla.XmlaOlap4jConnection$CubeHandler.handle(XmlaOlap4jConnection.java:1284)
at org.olap4j.driver.xmla.XmlaOlap4jConnection.populateList(XmlaOlap4jConnection.java:854)
at org.olap4j.driver.xmla.DeferredNamedListImpl.populateList(DeferredNamedListImpl.java:136)
at org.olap4j.driver.xmla.DeferredNamedListImpl.getList(DeferredNamedListImpl.java:90)
at org.olap4j.driver.xmla.DeferredNamedListImpl.size(DeferredNamedListImpl.java:116)
at java.util.AbstractList$Itr.hasNext(Unknown Source)
at org.olap4j.driver.xmla.XmlaOlap4jCellSet.lookupCube(XmlaOlap4jCellSet.java:520)
at org.olap4j.driver.xmla.XmlaOlap4jCellSet.createMetaData(XmlaOlap4jCellSet.java:403)
at org.olap4j.driver.xmla.XmlaOlap4jCellSet.populate(XmlaOlap4jCellSet.java:181)
at org.olap4j.driver.xmla.XmlaOlap4jStatement.executeOlapQuery(XmlaOlap4jStatement.java:372)
at com.socgen.moma.services.pricingassetscope.DefaultPricingAssetScopeManagerTest.testOlap4j(DefaultPricingAssetScopeManagerTest.java:184)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:47)
at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:44)
at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
at org.springframework.test.context.junit4.statements.RunBeforeTestMethodCallbacks.evaluate(RunBeforeTestMethodCallbacks.java:74)
at org.springframework.test.context.junit4.statements.RunAfterTestMethodCallbacks.evaluate(RunAfterTestMethodCallbacks.java:83)
at org.springframework.test.context.junit4.statements.SpringRepeat.evaluate(SpringRepeat.java:72)
at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.runChild(SpringJUnit4ClassRunner.java:231)
at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.runChild(SpringJUnit4ClassRunner.java:88)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:238)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:63)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:236)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:53)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:229)
at org.springframework.test.context.junit4.statements.RunBeforeTestClassCallbacks.evaluate(RunBeforeTestClassCallbacks.java:61)
at org.springframework.test.context.junit4.statements.RunAfterTestClassCallbacks.evaluate(RunAfterTestClassCallbacks.java:71)
at org.junit.runners.ParentRunner.run(ParentRunner.java:309)
at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.run(SpringJUnit4ClassRunner.java:174)
at org.junit.runner.JUnitCore.run(JUnitCore.java:160)
at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:78)
at com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:212)
at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:68)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at com.intellij.rt.execution.application.AppMain.main(AppMain.java:140)
14:17
For some reason, the code tries to build an XMLA element with a null unique name.
XmlaOlap4jElement(
String uniqueName,
String name,
String caption,
String description)
{
assert uniqueName != null;
Try sniffing the messages coming out of SSAS. There's probably something funky with the XML it returns.
Alternatively, you can take the high road and turn off assertions, but this error is a sign that something terribly wrong is going on and I recommend against this approach.
I am trying to setup tests using jUnit in my application. This is my first experience doing it.
Here is my test case:
public class TestClass
{
StudentDAO s= new StudentDAO();
#Test
public void testStudentsInQFG()
{
Assert.assertEquals(s.getStudentCountFromDB("1"),10);
}
}
Here is the Student DAO method:
public int getStudentCountFromDB(String CourseID)
{
String sqlCount="SELECT Count(*) FROM Student WHERE CourseID=?";
return this.getMySQLJDBCTemplate().queryForObject(sqlCount,new Object[] {CourseID}, Integer.class);
}
The method returns the right results when I call it from my Main method but the fails when I use the assertEquals. Here is my stack trace:
java.lang.NullPointerException
at com.omnitracs.fra.dao.StudentDAO.testStudentsInQFG(StudentDAO.java:107)
at com.omnitracs.fra.junit.TestClass.testStudents(TestClass.java:17)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:47)
at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:44)
at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:271)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:70)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:50)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:238)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:63)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:236)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:53)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:229)
at org.junit.runners.ParentRunner.run(ParentRunner.java:309)
at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:50)
at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197)
It looks like when StudentDao is calling your method getMySQLJDBCTemplate(), this method returns null (or directly throws an exception because it tries to access to access a variable which is not yet initialized).
You probably have to call have a method like setMySQLJDBCTemplate(jdbcTemplate) in your DAO, with a correctly initialized jdbcTemplate or a Mock (you can have a look at the library Mockito for that). You need to call it first in your test, to set the mysql template, before trying to access the DB. You may need to initialize as well other fields of your DAO.