I am bit confused about N-Unit Framework Testing. Below is my scenario for Web Application.
Create a Ticket
Assign a Ticket to User
Either User can work on Ticket or He may forward it for manager Approval.
Once Manager is Approved, he will work on that Ticket.
Close the Ticket.
How to create test case in N-Unit Framework. Below are my few questions.
Should i write code to create a Ticket? Can we insert a data to Database using N-Unit Framework.
If ticket is created, should we capture that ticket number and assign it to some user.
Should we write a code to assign it to user for approval?
I am not sure how to write N-Unit scripts for Wrokflow Logic.
When you write unit tests you usually write them so that they test one thing only. When testing a workflow you would typically split it up in several unit tests. In your scenario each point is a good candidate for a unit test except for number 3 that should be split up into at least two tests.
Should i write code to create a Ticket? Can we insert a data to
Database using N-Unit Framework.
It depends on your implementation. If you need a ticket for your tests then you have to create it first. No, you cannot use the NUnit framework to insert data into the database. That is not the kind of problem that the framework is intended to solve. Typically when writing unit tests you want to avoid accessing external resources like a database so try to write the code so that you don’t have to do that.
If ticket is created, should we capture that ticket number and
assign it to some user.
Should we write a code to assign it to user for approval?
This depends on how you have implemented the system. If you need this to run your tests, then yes.
Related
I have a project that uses FirebaseAuth, Firebase Database and Firebase Storage. The project is well advanced and needs to implement automated testing.
I have recently studied unit testing using ios XCTests. I understood basically how the native use of unit testing works and through the use of Mocks (Cuckoo specifically).
I arranged my code by removing dependency injections and something like that to prepare to implement the tests.
My question is that I needed to do tests like:
"When I perform a certain action on a ViewController, I wanted to check if it is saving a certain object in a Firebase Database collection (or mock), on the correct path."
Or better,
When registering a new user in the database (["name": "Mike", "email":"mike#email.com", "gender":"male"]), I would like to verify that it was actually saved in the path "/users/{mikeId}/{mike}".
I do not know if I was very clear, but I have doubts about how to test this kind of thing. Would I have to test the functions of my DataManager that do operations in the database? Create mocks that get this value and create a sort of fake database locally?
so it occurred to me that it would be helpful in the development of my backend to have a managed sandbox, like a development environment without having to set up a separate database. To be more specific I'm using Postgresql and Node.js, but I doubt that makes a difference.
So my question is, how do services such as PayPal commonly implement a "sandbox" for developers who use their API to play with that is separate from their real data? In my case all that I want is a database sandbox that operates separately from the main database for the backend developers. My first idea on this is to tag every row with their specific sandbox or production id, but that seems inefficient. Is there another way to implement this idea?
I have a very specific situation in an integration test.
I'm developing a Rest API composed by few micro services using spring boot. Some of those services have basically crud operations to be accessed by an UI application or to be consumed into internal validations/queries.
All the database manipulation is done through procedures by a legacy library (no jpa) and I'm using a non-standard database. I know that the good practices say to do not use real databases, but in this scenario, I cannot imagine how to use a dummy databases in the test time (like dbunit or h2). In this way:
1 - Is it ok to hit the real database in an integration test?
If 1 is ok, I have another question:
Usually, we do not change the data state in unit/integration tests; and the tests should be independent of each other.
However, in my case, I only know what is the entity id in the response of the post method, making difficult to implement the get/put/delete methods. Of course in the get/put/delete methods I can first insert and then make the another operation, but in this perspective, at the end, I will have a database in a different state of the beginning of the test. In this way, my another question is:
2 - How can I recover the database to the same status before the tests?
I know that it could be a specific situation but I really appreciate any help to find an elegant way of testing this scenario.
Thanks in advance.
You should ask differently: is the risk acceptable to run tests against your production db?
Meaning: if your tests only uncover problems in your code, everybody will be happy.
But if you mess up and the database gets seriously corrupted, and the whole site needs to be taken down for a backup that fails initially... So your business goes offline for 2 days, how do you think your manager will like that?
Long story short: it depends. If you can contain the risks- yes sure. But if not, look for other alternatives. At least : make sure that your manager understands what you are doing.
Integration test are fine and a must I would say as long as you don't run them in a production environment. It allows to test the overall application and how you are handling responses, serializations, and deserializations. Your test cases should handle what you expect to have in you production database and every test test should be isolated and what you create in your test case you must delete it after it so returning to its original state, otherwise you might have clashing test cases. Test integration tests in a local database or a dedicated testing database.
You can specify the in memory H2 database for interface integration testing and populate it as needed for specific tests. This is useful when you are running in situations where having a database on your Jenkins or similar unit test system doesn't make sense. It really depends what you are testing ie end to end integration or finer grain integration.
I am trying to determine whether I am able to inject test case information at run time and leverage the SOAPUI tool. I understand that I can create test cases on the GUI but is this my only option?
Background info if interested: Currently I am working on creating an automation framework at my company. We currently have web page testing and soon to be added SOAP testing. As many of these tests (at one point in the future as I am told my the architect) could be run from both a web page and soap I think it's best to store the test cases in some format (Json, YAML, etc.) to document all the test cases and then inject them into test steps at run time.
However my company enjoys working with SOAPUI. I've used the tool and created test cases, assertions, et al on the GUI (of course) but I cannot find any documentation which suggests that instead of defining the test cases in this way I could inject the test information at run time (similar to what you can do with the wsdl2java apache tool). Can this be done with testrunner? This way I can reuse the test cases. Is this possible? Does this even make sense? I just want to attempt to incorporate a tool I've been asked to use.
Any thoughts are greatly appreciated!
Here is an example of what data may look like:
Partner : [
Organization : [
Company Name:
Company URL:
]
Contact Information : [
Name:
Address:
]
] (sorry i can't get the indents to work properly...)
As I stated below in a comment, I know on the SoapUI GUI I can create a test suite, test case and add test steps. But I want to store the test step information in a different place so I can use the test steps for different kinds of tests.
Your question is way too broad for me to even attempt a complete answer.
SoapUI GUI you use to create the tests. Your data can be stored, and read by SoapUI, in Excel, database, flat file, generated dynamically, whatever you want. You can run everything using the testrunner from command line, or using the Maven plugin from Jenkins.
Seriously, spend some time with the documentation.
Hi in my project we are doing an import if lets say products.
We will have a web service where we will get maybe 10 calls for one import, so we need to have a transaction that can be over several requests.
The import will have both new products that needs to be created and existing products that needs to be updated.
Right now the only way we can know if the product is already in our system or not is to look at Name or Previous Name on the Product we want to import.
So basically my questions is.
Can the transaction API described here http://ravendb.net/docs/client-api/advanced/databasecommands, Be used for the Batch api described here http://ravendb.net/docs/1.0/client-api/advanced/databasecommands/batch. (which it sounds not to work together if one read the batch api documentation).
And if not should I use the database commands connected with an transaction? But in the documentation for databasecommands I can't see how the transaction guid and the operations can be connected?
The easiest way to handle that is to aggregate things in memory and have just a single SaveChanges call in the end.