We are looking for a framework to test our MarkLogic XQuery code.
We can see MarkLogic/XQunit is a good framework, but it does not have code coverage feature.
What is the best framework to write unit test cases for MarkLogic XQuery?
Two unit test frameworks I've seen used in practice are XRay and Roxy Unit Test (note that Roxy Unit Test is part of a larger project, consisting of the Roxy Deployer, MVC structure, and Unit Test; the Unit Test feature will be easiest to use if you're also using the Deployer). Roxy can test XQuery and Server-side JavaScript code.
I'm not aware of any tool that provides code coverage at this time.
Edit: Rob Rudin has made the Roxy Unit Test framework more accessible to gradle projects: https://github.com/marklogic-community/ml-unit-test.
Edit 2: ml-unit-test now offers an experimental code-coverage feature
Related
I'm trying to learn a methodology or some design pattern for integration testing.
I'm not talking about unit testing or using mocks for unit testing.
I want to test some fetcher that involve several functions or some flow E2E.
I am pretty confuse with unit and integration testing of traditional software development and web development. I have seen many different answer and explanation of it.
The Web Engineering textbook says about unit and integration testing for web application:
Unit testing: Testing on single web page as opposed to testing single function
Integration testing: Testing on flow of data from one web page to another (and linkage)
while the software engineering textbook defines unit testing and integration testing as followed.
unit testing: Testing on smallest unit
integration testing: Testing on interaction between unit or module
Hope someone can clarify to me which is the correct one.
The "web engineering" textbook is... likely wrong. That's not what those words mean to most folks.
Unit testing: testing the smallest possible bits of functionality, independently. For Java, something like the JUnit framework is used to do this. You often try to test just one class, and you may fake it's dependencies using something like Mockito, so you're really testing just one thing.
Integration Testing: testing several parts of the system together. This may be a small integration test (testing multiple classes without mocking), or something large, like making sure that your webserver is connecting to a database correctly.
End-to-End Testing: the biggest Integration test; this is basically standing up every part of your system and running scripts that look like fake users. Selenium is a tool used for this.
I am new to testing in general and am working on a Grails application.
I want to write a test that says "when this action is called, the correct view is returned". I don't know how to go about deciding if I should make something like this a unit test or an integration test. Either test would show me what I want - how do I decide?
One problem with integration tests is their speed. For me, integration tests take 15+ seconds to start up. In that time, certain things do slip out of mind focus.
I prefer to go with unit tests that start in no more then 2 sec and can be run several times in those 15 seconds. Especially with mockDomain(). Especially with Grails 2.0 implementing criteria and named queries in unit tests.
One more argument for unit tests is they force you to decouple your code. Integration tests always tempt you to just rely on some other component existing and initialized.
From Grails Docs section 9.1
Unit testing are tests at the "unit" level. In other words you are
testing individual methods or blocks of code without considering for
surrounding infrastructure. In Grails you need to be particularity
aware of the difference between unit and integration tests because in
unit tests Grails does not inject any of the dynamic methods present
during integration tests and at runtime.
From Grails Docs section 9.2
Integration tests differ from unit tests in that you have full access
to the Grails environment within the test. Grails will use an
in-memory HSQLDB database for integration tests and clear out all the
data from the database in between each test.
What this means is that a unit test is completely isolated from the Grails environment whereas an integration test is not. According to Scott Davis, author of this article, it is acceptable to write only integration tests...
Unit vs. integration tests
As I mentioned earlier, Grails supports two basic types of tests: unit
and integration. There's no syntactical difference between the two —
both are written as a GroovyTestCase using the same assertions. The
difference is the semantics. A unit test is meant to test the class in
isolation, whereas the integration test allows you to test the class
in a full, running environment.
Quite frankly, if you want to write all of your Grails tests as
integration tests, that's just fine with me. All of the Grails
create-* commands generate corresponding integration tests, so most
folks simply use what is already there. As you'll see in just a
moment, most of the things you want to test require the full
environment to be up and running anyway, so integration tests are a
pretty good default. If you have noncore Grails classes that you'd
like to test, unit tests are perfectly fine.
First go through this chapter of the grails guide http://grails.org/doc/latest/guide/9.%20Testing.html
It talks about testing controllers and ability to get controller response like so :
controller.response.contentAsString
Now deciding on which test is more of an art rather than science. I prefer unit tests cause they are faster to run :)
Its a really interesting and challenging question to answer, but the truth is it really depends on what exactly you are testing.
Take the following test: "saving a book to the database". The hints are in the description. We are saying we need a book and we need a database, so in this case a unit test wont do because we need the integrated database.
My advice is write the full test description down and break it down like I did above. It will give you the hints to help you decide.
This is made easier with spock where you can use strings for test names.
We are starting to build infrastructure components in JSF2.0.
What is the best approach for unit testing them?
I tried JSFUnit in the past but wasn't satisfied with it. Is there an easier way to implement it?
This may be more integration testing than unit testing, but if you want to see how your components work in an actual browser, the selenium project has some nice features, and you can do it all through unit tests. You can look it over here: http://seleniumhq.org/docs/03_webdriver.html. I've found that between regular unit tests, unit tests using jmockit or the like, and selenium, I can cover pretty much everything when testing my components.
Cheers,
Bill
I would like to know what a Unit test and Web Test is in the .NET Framework and What are the difference between these tests? and How does it affect with the implementation of the CSLA.NET? Please help, thanks!
I guess you're referring to using MSTest under Visual Studio where they have two modes - testing of code or testing of web site via http calls.
When developing in .NET a developer can choose from several Unit Testing Frameworks such as MSTest - NUnit, MBUnit, XUnit etc. for more information have a look at this question.
The term Unit Testing refer to a broader field - you can read about it here.
Unit testing refers to the programmer writing simple small tests to verify his code actually work and as such does not effect the implementation of CLSA.NET.
I would like to know what a Unit test
and Web Test is in the .NET
Do you mean, what unit tesing frameworks are there for .NET ? I recommend you NUnit