Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.
Closed 7 years ago.
Improve this question
How can I unit test a JSP? I want to ensure there are no tag misspellings, etc.
I am already aware of the HtmlUnit/HttpUnit/JWebUnit/Selenium possibilities for System testing. I want more of a unit test.
I would say that testing a web app (be it JSP or other) using its web interface, with one of the above mentioned frameworks is not unit testing in the strict sense. Unit testing means testing small parts of your app (one method, one class) in isolation. With a web framework, you test the web app as a whole, so this is more like system or integration test. Which is not to say it is not useful - on the contrary - just it is better to clarify terminology.
Having said that, if I were to test a JSP, I would most likely be satisfied with a system test of all specific scenarios associated with the JSP, using some of the tools mentioned above.
However, if you really want "classic" unit tests, I guess the closest you can get is compiling your JSP into a servlet class, then calling the servlet methods directly (from e.g. JUnit, using a mocking framework like EasyMock to prepare the Http request, response etc. objects).
Update: IMO the only reason to need unit tests for a JSP is if you have business logic in it. Which, in turn, goes against the separation of UI and business layer. So it is better to redesign the app and move the logic into a separate POJO (if you have the choice) than try to write contrived unit tests in order to test business logic where it doesn't belong.
Related
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 1 year ago.
Improve this question
Whoever writes unit tests in Go, how are you documenting them?
Is there some kind of 'docstring' (like in Python) convention?
If so, how do you maintain this documentation afterwards?
Is it possible to generate Docs based on the description from Unit tests with some automatic tool?
I am asking because as a QA person in my team i wish to document those tests and maintain them as a part of an ongoing dev cycle.
Whoever writes unit tests in GoLang, how are you documenting them?
Not in any systematic way (if at all).
Is there some kind of 'docstring' (like in Python) convention?
No. (For executable examples there is of course.)
If so, how do you maintain this documentation afterwards?
NA. Nothing to maintain.
Is it possible to generate Docs based on the description from Unit tests with some automatic tool?
Asking for 3rd party software/libraries is offtopic on SO.
about automatic documentation, take a look on godoc - https://go.dev/blog/godoc
i don't know about specific usage of unit-test in golang (everyone using it - same as in other languages), but besides them bdd is also popular, for such a stuff take a look on godog - https://github.com/cucumber/godog
about Asking for 3rd party software/libraries is offtopic on SO - golang is all about 3rd party libraries :)
p.s. probably you can use pattern godo(.{1}) to find any packages for go :)
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.
Closed 6 years ago.
Improve this question
I am looking for a free QT UI testing tool for Windows. I have unit tests for my backend modules using boost::Test. However, the UI has more potential to malfunction and I would also like to test this.
The testing frameworks that I found using the search function on Stackoverflow only involve a few frameworks - and those do cost. Also, it should be usable with an LGPL project.
Is there any free way to do it?
Testing / Troubleshooting User Interfaces is a very tough process.
Classic unit-test frameowrks (QTest, boost, gtest) are usefull for testing non-interactive modules, classes, functions.
When inputs are required, things become much complicated.
You could choose a "mocking" framework such as gmock to "simulate" a user input.
But if your GUI application has many windows, dialog-boxes, gui elements it might become a real pain in the neck.
There is a second approach that I recommend.
I spent years developping applications with Qt. My first applications did not respect any MVC model.
The debugging and the code tuning was very painfull.
I also made an effort to separate the logic from the user-interface as much as possible.
Just like the MVC model of Qt (QAbstractItemModel).
This way, you're able to test your models in regular unit-tests frameworks.
You can extend this logic to all of your gui components.
Finally, you'll still have to perform "human tests" to troubleshoot your application.
But this is a normal phase in the development process.
There's only a human resource that could use your software, click anywhere in the windows, dialog-boxes, do weird things etc
That's the best way to find out unbelievable GUI bugs !
Not a unit-test can find them out.
A developper cannot reproduce the behavior of the person that will use your software.
Because we unconsciously know where bugs may occur...and thus, we often don't click where it's not recommended...
Think about it.
Z.
Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 8 years ago.
Improve this question
I still read that without unit testing, you cannot be agile. While I understand the purpose of unit tests, why they are so crucial in agile? Is it because the frequent builds might easily brake something?
And what about integration testing in agile, is that the same case?
Thanks
"...without unit testing, you cannot be agile". Strictly speaking, that is a false statement. Agile doesn't prescribe a particular testing methodology. Anybody who tells you otherwise doesn't understand agile. Agile is about delivering high quality code and being able to respond to change. If you can do that without writing unit tests, you can still be agile.
That being said, unit tests are an important part of software development no matter what the methodology. It's difficult to write high quality software on a large scale without them. They help you determine that the individual units of your code are behaving the way they are designed. Whether you use unit tests, and how many unit tests you write, is a factor of how important it is that your code is correct, how hard it is to fix defects if they make it into production, and so on.
I would say that for most projects, having a robust, well-maintained set of unit and integration tests helps your team be more agile. Having a good set of unit tests is very liberating as a developer -- you are free to make changes more quickly because you have a safety net. This makes it easier to quickly develop stories and verify they are correct.
Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 8 years ago.
Improve this question
I recently had an argument with my supervisor about unit testing. My office is currently working on DRs for an upcoming release and he has created a DR process. One of the steps is to develop a unit test for your DR. This is where we differ greatly in opinion. He told me that this test is performed through the user interface and that the difference between functional and unit testing is that unit tests are more localized. I am of the opinion that a unit test has to be code based because it should only test a single part of the code and this is the only way to isolate it. I also said that unit tests were almost exclusively done in frameworks (such as jUnit) for every part of development e.g. development or maintenance. I would like some people to weigh in on this. Can unit testing be done through the user interface of an application? What is the most common way to achieve unit testing?
*Note: Yes, I did google it but most of what I found was vague enough to accommodate both of our conflicting ideas. I am looking for more real world answers. Thanks for your time.
He's wrong. A unit test is a unit test because it isolates dependencies and tests a single aspect of your code. A test that runs through your user interface isn't a unit test simply because even displaying the UI involves dozens of dependent interactions, none of which you can isolate or control for the duration of your test.
Testing frameworks are irrelevant. You can be using a "unit testing" framework and still write something that's not a unit test. For example, you write a test that writes a file to the file system, and you assert that the file exists. Well, your file system is a dependency that you didn't isolate. You wrote an integration test, not a unit test.
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.
Closed 7 years ago.
Improve this question
I'm curious if there are any free open source projects written with ColdFusion (CFML) that have substantial unit testing or other forms of automated testing already done for the core features?
I'd like to consider basing some of my open source project on existing code if the implementation is following more best practices and has automated tests.
For example, a library for handling form / validation. A library for string manipulations. Database handling, etc.
Edit: MXUnit is fine for unit testing framework, but I'm asking more about non-testing frameworks that have implemented unit tests to verify their features.
If you're looking to get involved in an open source project that is pro-unit testing and involves form / validation then have a look at ValidateThis - http://www.validatethis.org/
When I've added to the framework in the past the guys supporting it have asked for tests to be included where at all possible so there should be plenty there to get you started. I'd advise asking on the VT forums for more information and on how you can support the project.
If you're looking for a unit testing framework for your own projects then I'd recommend MXUnit (http://www.mxunit.org/) which is certainty the most popular U.T. tool in the ColdFusion community at the moment.
In terms of application frameworks that have built in testing features I can only comment on one and that's ColdBox (http://www.coldbox.org/) which I know is built upon MXUnit but also includes a pile of other features including their own mocking tool - Mockbox (http://wiki.coldbox.org/wiki/MockBox.cfm)
Bruce, The ColdBox MVC Platform has always published its Unit Tests as part of the GitHub repo:
https://github.com/ColdBox/coldbox-platform/tree/master/testing/cases.
Since you mentioned validation, here are the tests specifically for ColdBox's validation engine:
https://github.com/ColdBox/coldbox-platform/tree/master/testing/cases/validation
You will need to tweak some settings to run them locally, but they are all there.
Since you mentioned wanting to build reusable libraries, please check out ColdBox plugins (for small chunks of reusable code) and ColdBox Modules (For more complex functionality that uses all pieces of the MVC platform).