How to do unit testing in kdb language? - unit-testing

Has anyone has done kdb unit testing before? I have no idea how I should do unit testing. I am confused about time store unit testing as well.
I will load my script, Qunit script and test script. However, I am not sure how to write the test code for queries. What should I write for expected result?

QUnit a unit testing framework for kdb is documented here:
http://www.timestored.com/kdb-guides/kdb-regression-unit-tests
With the source code being available here:
https://github.com/timeseries/kdb/tree/master/qunit
If you have any specific questions, just ask.

Related

Is Karma absolutely necessary to run Angular 2 unit tests?

If this is a silly question, I apologize, but I am sincerely having a hard time understanding if we absolutely need Karma to run unit tests? I am new to Angular 2, Karma and Jasmine, and I was hoping someone with more experience than me could explain if we could just use Jasmine standalone to run unit tests.
I know that Karma is a test runner, and I know all the niceties that come with Karma (test on multiple browsers and devices, automatically rerun tests when files are changed, test coverage results, easy integration with Jenkins .. the list goes on and on!). But I am just having a hard time understanding if it completely necessary. A lot of the examples I've seen (if not all of them) use Karma, but I have not seen an example where only Jasmine is used, and would like an explanation why. Is it because of how Karma loads the spec/app files?
An example I was looking at was Jasmine standalone, and I am trying to use this example to apply to my current structure, but so far no luck:
https://github.com/jasmine/jasmine/releases
Thank you in advance for all your help!

TFS and Unit Testing

Firstly just let me explain my situation.
I am working on a legacy code. I try to cover a part of code with unit tests then refactor it. When every thing goes well, I will explain it for the manager and after approval, We will check in change sets to main solution.I use MSfakes to write unit tests. Nowadays I am trying to manage unit tests, for example I've wrote test cases in TFS for every unit test.
What is your idea about managing unit tests in TFS? If you are writing unit tests and refactor a legacy code, What is the best usage of TFS for you? Writing use cases and connect them to the unit tests? any more?
Please let me know if you had any experience that TFS helped you in managing your unit tests.
Thanks

When to Unit Test and When to Integration Test

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.

JUnit for JSF2.0 composite components

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

Unit Testing for the web?

I have been doing a lot a reading about unit testing.
Unit testing seems all well and good.
But it seems to miss a lot of the fundamentals of how the web works. User Interaction.
I have not seen any way a unit test could test for unexpected input, or test to make sure that an ajax call works etc.
Am I missing something here or is unit testing not really designed well for web development?
You are not missing anything.
Ideally unit testing is about testing a small piece of code, e.g. a class in isolation. For this you may want to use a unit testing tools such as JUnit or NUnit. Some people refer to this type of tests as developer tests.
In contrast to that you may want to test web applications as a whole. Some call this acceptance testing. For the latter you could use a tool such as Selenium. Tools like Selenium can test Ajax and other JavaScript as well.
You have even more options if you take a look at a tool like WebDriver as you will find that you can implement Selenium-based tests using a unit testing tool.
Take a look at Selenium.