-2

I have a java file that has connection strings and simple create and select sql statements. So how can I write a JUnit test to make sure it works or not? The file doesn't have main method according to project description.

GoGo
  • 2,727
  • 5
  • 22
  • 34
  • Describe what you have tried so far and show some sample code please. – trylimits Mar 22 '14 at 16:56
  • Your question is too vague. Read a tutorial on Junit, write a test, and ask a specific question if you get stuck. – Cory Kendall Mar 22 '14 at 17:20
  • 1
    You could use [DbUnit](http://dbunit.sourceforge.net/) to test your SQL statements. Were you only interested in testing your queries and results? – Makoto Mar 22 '14 at 17:22

1 Answers1

1

You can test a connection, but you have to use a framework like mockito to mock the JDNI resources, you can see an example in:

How to mock InitialContext constructor in unit testing

it's works (i test just a few minutes ago), good luck ;)

Enrique San Martín
  • 2,202
  • 7
  • 30
  • 51