how to setup test suite in ruby? - ruby

i am writing few ruby scripts and i wanted to write Unit tests and integration tests for it.
i learnt that test/unit module is present in ruby.
in my scripts, i wrote ruby classes A and B which extends the common helper class Common
in both the class, i am trying to setup S3 connections.
i wrote A_test, B_test test cases.
when i run them individually, they work.
when i put together, they are not working. some of the variable in the initialize are getting set only for the class / tests which runs first.
if A_test is running first, then it works.
B_test doesnt work.
any reason?

I can not answer your question well without some code samples, but consider the possibility that it's the code being tested that's the problem, not the tests.

Related

It is there a possible way to create some Global Steps Hooks in parallel execution for cucumber 4?

Parallel execution of cucumber 4 work for me, but I want to execute some actions just once for all tests, It is a possible way to run some hooks in another Thread ?
As per your requirement, you want to execute some actions for all test cases once, is it like before or after all test case execution. If so then adding #BeforeClass from JUnit/TestNG and Similarly you can use #AfterClass in your run cuke class. This piece of code would run once before running your first class and after all test execution completed.
would it may work or adding tagged hooks give you some clue. Like for some specific test cases you can use tagged hooks and run those specific actions inside that hook only.

How do I verify my LoadRunner test scripts are actually being executed?

I've a requirement to load test a web application using loadRunner(Community edition : 12.53 ). Currently I've my test scripts recorded using loadrunner default test script recorder. I'm assuming that, the operations I chose to perform in SUT should actually update the application backend/DB when I'm executing the test scripts. Is this the correct behavior of a load testing scenario?
When I ran my test scripts, I couldn't see any value or nothing updated in the application DB.
I've my test scripts written in C and also manual correlation is applied using web_reg_save_param method.
What might be the things that could go wrong in such a scenario?. Any help would be deeply appreciated.
the operations I chose to perform in SUT should actually update the application backend/DB when I'm executing the test scripts. Is this the correct behavior of a load testing scenario? - Yes this is the correct behaviour.
When I ran my test scripts, I couldn't see any value or nothing updated in the application DB. - Something you might be missing in the correlations. this generally happens when some variable is not correlated properly or gets missed. Or something like timestamp that you might think is irrelevant but needs to be taken care of.

Is it possible to show output by test method in Gradle?

I find gradle has already supported showing output by test class. It's quite useful for debugging when test fails on Continuous Integration Server.
I'm wondering is there a way to show output by method instead of class which will be even better. Sometimes, a test class has many test methods which makes the output still hard to inspect.

Pass parameter to Rspec test on the command line

I am trying to use RSpec to functional test my REST apis.
The way I would LIKE it to work is using a CI build to build and deploy my application to a test server somewhere in the cloud and then have it kick off automated functional tests. But in order to properly do that, I need to be able to pass in the base url/domain for where the app was deployed. It will not be the same.
Everything I've found so far makes it seem like RSpec can't do this. Is there another way to do it if I can't pass in parameters on the command line? Or is RSpec not the right choice for this?
One way would be to bypass the call to rspec with something that accepts command line arguments and then initiate rspec in code. If you do not want to write your own binary for that, rake is capable of that too.
Look here for how to run rspec from code.
Another way would be setting an ENV variable when calling your test and preferably making it optional in the specs.
$> SPEC_URL=http://anotherhost:666 rspec
in code:
url = ENV['SPEC_URL'] || "http://localhost:4000"
I would suggest method two as it's the cleaner and easier approach in my opinion.

rspec setup for integration tests

I want to set up some database state for integration tests. My basic setup looks like this:
describe "some behaviour" do
before(:each) do
<setup some mock objects with stubs>
<call the database set up script>
end
end
Setting up the mocks naturally belongs in a before(:each), the examples depend on the mocks.
The database setup script is slow, so I only want to call it once.
Part of the process being integration tested is the database setup script. While I can change the script to make it easier to test, I can't remove its dependency on the state of the mocks.
The database setup must be called after the setup for the mocks because it depends on them. E.g. some of the mocks return identifiers which the database setup script needs to put in database records.
So really I want to put the database setup in a before(:all). before(:all) causes the setup to be run before the before(:each), so I can't see how to meet all the requirements.
I tried to split out the setup of the mocks into a helper function, which I called as the first call in both the before(:all) and before(:each). rspec doesn't allow creation of doubles in before(:all) blocks, so this didn't work.
Is there any way to run the slow database setup only once, but still have the mocks available?

Resources