How to write any variable created in a test to the jasmine-reporters output file using Protractor? - jasmine

In parts of my test, I have some variables I dynamically create that simply capture some strings. I have jasmine-reporters set up and working, and writing to an output.xml file. How do I get any variables I create in my tests to write to that output file?
For example, if I do a search in my test, the results display number of lines in a string as part of what's returned. I do a getText() on that and store in a variable. I have figured out how to write to console, but it would be great to get it to write to the output file instead.

Yes like #bloveridge mentioned, jasmine does not allow you to add data from the tests into the report, and you should not try to do it as it's not the concern of the test reporter. If you want to use protractor to collect some kind of information while testing, you should write into your own (i.e. separate) file (http://nodejs.org/api/fs.html) in your test.

Related

Using flexible file writer in Jmeter produces unwanted results in the output csv

I am using the flexible file writer in Jmeter to write the four variables that I have captured and defined in the properties file. I have used the debug sampler to verify and view results of the values of each of the 4 variables that I have used.
But when I am trying to use number of threads as more than 3 or 5, I am getting garbled and multiple values of the variables in the same column of the output csv as:
But ideally I am expecting the result to be like:
Timestamp_Queued|Timestamp_Download_Started|Timestamp_Download_Completed|Timestamp_Completed
1623596826050 1623596829514 1623596829868 1623596830045
1623596826195 1623596826434 1623596826840 1623596827071
1623596826427 1623596827736 1623596828138 1623596828319
1623596826629 1623596830096 1623596830417 1623596830600
1623596826809 1623596827113 1623596827514 1623596827692
Can someone help please. I have tried using other JS to capture the data one below the other but I am not able to capture the data in the above way. I am sure Jmeter must have an easy way to accomplish this.
Thanks!
We cannot help you by looking at the screenshot of the result file, we need to see your configuration of the flexible file writer, know how do you launch your JMeter script, is there any suspicious entries in jmeter.log file, etc.
Given that:
You declare your variables as Sample Variables
Configure the Flexible File Writer to save these variables as variable#0,variable#1,etc
Run JMeter in command-line non-GUI mode
You should get the anticipated results
More information: Using the JMeter Flexible File Writer Plugin

How can I embed a test data set in my JMeter test plan?

At the moment, my JMeter test uses a CSV Data Set Config to iterate through a limited set of input data for each HTTP request that I do.
But I don't want to deal with the hassle of an external file (uploading it to my test runner, etc.) - I'd like to just embed the data into the jmx file itself.
I was hoping for something like a "test data" node, that would work similarly to a CSV data set (with Recycle on EOF especially) and I'd just copy/paste the data into the test plan instead of working with an external file.
I'm thinking I might be able to work around it with a JSR223 preprocessor - but is there a better built-in way?
Edit: As per comment: the data cannot be generated.
If you want to do this via JSR223 Test Elements and Groovy language correct syntax would be
vars.put("messageId", "wibble");
vars is a shorthand for JMeterVariables class instance, see the JavaDoc for available functions and properties.
Easier way would be going for User Defined Variables or User Parameters or even better Set Variables Action
You can create a text contains keys and values separated with tab, copy all text
Notice if you have property file you can replace = with tab
Add to JMeter GUI User Defined Variables and click Add from Clipboard
It'll load all your variables to JMeter without "do that by hand using JMeter's GUI"
.
This is my first go at a script based approach using a JSR223 preprocessor node:
// This is where the data is embedded. Up to a couple of hundred entries
// is probably fine, more than that will likely be a bad idea.
def messageIdList = ["graffle", "wibble", "wobble", "flobble", "gibble", ...]
def messageIndex = (vars.getIteration() -1) % (messageIdList.size() -1)
println "iteration ${vars.iteration}, size ${messageIdList.size()}, index: ${messageIndex}"
vars.put("messageId", messageIdList[messageIndex]);
messageIndex++
This appears to do what I want, even when run in a Thread Group with multiple threads.
I'm not sure exactly what the vars.getIteration() represents, and I'm not clear about the precise lifetime / scope of the variables. But it'll do for now.
Any better answers will cheerfully accepted, marked and upvoted.

XCTest UITesting - Import test cases and export test case results

I'm writing UITest cases to my application using XCTest. Some test cases needs some input.
Consider that I'm writing test case of my login page. Login page needs Username & Password. I should check invalid username, invalid password, empty fields, valid username and password all these scenarios. These inputs (Username & Password with various combination) was set in the test classes.
I want to separate this inputs from test classes. I should give outputs from outside. So I created a plist file, which includes username & password combination. I imported plist file's data and gave it to the test cases.
Question: Is this approach fine? Or should I do any other way to pass inputs to my test cases?
Coming to the output part, after the test cases was completed, we can see the test results in "Test Navigator" panel. (Passed results are shown with green tick mark, where the red one shows for failed test case).
I want to export these results from Xcode, so that I may present the results in a webpage, or I may want to print results in a text file, etc.
Question: Is this possible? If yes, can someone explain on it?
Just confused!!
You can use either plist or Json file for the parameterization of the tests. To parse the output you can use xcpretty which is widely used formatter for xcodebuild, it generates the output as Unit-Style XML or html as well.
You can trigger the tests from command line using xcodebuild test and pipe the output to xcpretty
After some research, I wrote an util class that can take plist, json object, txt file as inputs. It will convert them into the NSDictionary then it will use the needed data as inputs.
For the output part, I am using OSX Server. The build-in outputs are more elegant than my expectation. Thanks to Apple!!

Arbitrary checks in ReSharper plugin testing

As I learned from DevGuide testing ReSharper plugins works as follows:
Plugin is loaded and test input file is passed to it
Plugin performs it's actions on the passed file
ReSharper's test environment writes plugin actions results to .tmp file in a special format that depends on the type of functionality tested (for example, if we test completion, .tmp file will contain the list of generated completion items)
ReSharper's test environment compares .tmp file with .gold file to decide if test is failed or succeeded
But I need the following scenario. The first two steps are the same as the above ones, then:
I write code that obtains the results of plugin's actions and check are they what I'm expected so I can make test fail if needed
How can I achieve this?
I need it because I have a code that uses AST generated by ReSharper to build some graphs and I want to test are the graphs built correctly.
Yes, you can do this. You need to create your own test base class, instead of using one of the provided ones.
There is a hierarchy of base classes, each adding extra functionality. Usually, you'll derive from something like QuickFixAvailabilityTestBase or QuickFixTestBase, which add the functionality for testing quick fixes. These are the classes that will do something and write the output to a .tmp file that is then compared to the .gold file.
These classes themselves derive from something like BaseTestWithSingleProject, which provides the functionality to setup an in-memory solution and project that's populated with files you specify in your test, or BaseTestWithTextControl which also gives you a text control for the file you're testing. If you derive from this class directly (or with your own custom base class), you can perform the action you need for the actual test, and either assert something in memory, or write the appropriate text to the .tmp file to compare against the .gold.
You should override the DoTest method. This will give you an IProject that is already set up, and you can do whatever you need to in order to test your extension's functionality. You can use project.Solution.GetComponent<> to get at any shell or solution component, and use the ExecuteWithGold method to execute something, write to the .tmp file and have ReSharper compare to the .gold file for you.

jmeter not saving variables into CSV or XML files

I'm new to jmeter.
I understand that I can edit jmeter.properties and specify the names of "custom" variables that jmeter will save into its output files, for any given test run.
I've edited jmeter.properties to include this line:
sample_variables=DURATION
and I've also edited my test plan to include a Regular Expression Extractor that extracts a value from each response and stuffs it into a variable of that name.
I also added a "Simple Data Writer" to tell jmeter to write the data it collects to a file.
The output file gets created successfully, but it does not contain the variable I extracted.
What am I doing wrong?
I'm finding this impossible to google, because "save jmeter variable" doesn't constrain the situation nearly enough.
My bad.
Jmeter was writing that variable out.
I had to restart jmeter to get it to work.
I was misled by looking at the top of the output file - it contained output from a prior run, prior to my restart of the tool. After I Removed the existing output file, the new content in the output file showed the variable I expected.

Resources