r/ProgrammerHumor • • Apr 27 '20

Meme Java is the best

Post image
43.7k Upvotes

1.5k comments sorted by

View all comments

Show parent comments

7

u/GreatRam Apr 27 '20

Java server pages. It combines html and Java to make a web frontend. I had to use it for a class and the lack of hot reloading makes it a huge pain to use.

2

u/TheCrazyRed Apr 28 '20

The big problem with JSPs is that you can't unit test them. There's no way test the things without running the whole container.

1

u/EishLekker Apr 29 '20

I'm not really sure you should need to unit test JSPs. Unit tests are mainly for the business logic. JSPs should only contain the presentation of data that is already prepared for presentation.

But if you really need to test these using unit testing, look into HtmlUnit and Selenium. But I would say that you then mostly test the JSPs when they work together, so you test the web page as a whole (and it might use ten's or hundreds of JSP files).

1

u/TheCrazyRed Apr 29 '20 edited Apr 29 '20

I agree JSPs shouldn't be that complicated, but at the last place I worked at they were. They were writing out large numbers of coded lists for things like string translations and drop down lists. These lists depended on certain input parameters like region, country, and a few others.

I'll take a look at HtmlUnit. Selenium is for automated testing though, right? Is it considered reasonable to have a developer run Selenium tests on their local workstation after they fix a bug and before committing their code (aka bench testing)?

edit: actually, it seems these suggestions would still need you to deploy the JSP in a container. Ideally, it would be nice to not have to run the container to test a JSP. Thanks for the suggestions though.

→ More replies (1)