How easy is it to test Java classes?

We have an existing Tomcat / Linux / Servlet / Java web server, but we no longer have a developer. We have C # / Windows code (a desktop application) that does the same type of calculation / data manipulation as a website. I study why they give slightly different results.

To achieve this, I would like to write a small test exe java that calls the code with specific input and spits out the output + some debugging information.

My main problem is that I'm new to Java: where do I start writing this exe and calling existing classes (instead of Tomcat calling these classes somehow)?

I have an Ubuntu VM with Eclipse. Java source code is installed and compiled.

My main question is about how to set up an exe program project in Eclipse and set up the necessary links to call these exsting classes. This is not about the Java language itself (I know C #, which was eventually inspired by Java)

TIA

+3
source share
5 answers

You should be fine, just run some JUnit tests (almost the same as NUnit).

You can add a new package with links to packages of other classes and write tests for them.

For more information you can check out some JUnit docs

If you need to test your servlets, a neat way with Jetty + Junit. More information on this subject can be found here.

+4
source

exe java ( ), , Jar. jar. , JUnit .

eclipse eclipse. . , , . . log4j, . eclipse , , - .

mockito, , . , mock HTTPrequests respones.

+2

Eclipse JUnit, defacto Java. - -, , , - . ServletTester .

+2

JUnit ,

, JUnit mockito - . . , , - , .

, eclipse.


( )

, , tomcat . eclipse , . , - . , , .


tomcat Eclipse. BlazeDS, Tomcat. - , , .

, ,

  • gMale
0

[: OP]

. . .

, main() Shift + Alt + X, J, main() Eclipse. , 2 .

, , JUnit, , , , , , , , .

.

0

Source: https://habr.com/ru/post/1772673/


All Articles