Credo output format - junit

I am automating the process to test my code and am using credo to test the format of my elixir code. I want to output the results and because I am using CircleCI I need the results to be in Cucumber JSON or JUnit XML. How do I configure credo to output one of these, I am currently using:
mix credo --all --format=json > credo-output.json
which as expected will give me normal json. Is it possible to either configure credo to output what I want or to convert the json to another format?
Thanks

Related

JUnit 5 report to json or test runner with json reporting

I have a test documentation tool which accepts reports in XML and JSON. I need to attach screenshots to every test case even the passed ones. Unfortunately, the tool (xRay for Jira) can only digest screenshots in a form of JSON and cannot in XML.
I know that cucumber does reports in json but I do not want tests to be BDD-like.
Is there a test runner, which can do reporting in JSON or a solution on how to convert JUnit 5 XML report to appropriate JSON format with screenshots in Base64.
Current set up is Java/Gradle/JUnit5/Selenide but can be reviewed.
Importing attachments, as of today, is supported if you use Xray JSON or Cucumber JSON reports.
The only way, right now, would be to implement either a JUnit5 TestExecutionListener or a TestWatcher that would generate a Xray JSON report.
Note: in the short term, support will be added for JUnit 5 and also for TestNG; currently, this is experimental and not yet supported in the product but please raise a support request asking for this improvement, so the team can track your interest on it. The URLs for the previous repos will probably change.

Request a specific variable of JSON stream using bash/terminal

I am working with a flutter web server testing. I writing a simple bash script to fetch some JSON data from API request. The API request dispatch following information as JSON response.
{
"code_version":{
"engine_name":"flutter_renderV1",
"proxy":"10.1.1.1:1090",
"test_rate":true,
"test_density":"0.1",
"mapping_eng":"flutter_default_mapper"
},
"developer_info":{
"developerid":"30242",
"context":true,
"request_timestamp":"156122441"
}
}
Once this received, I saved in to local file named server_response{$id}.json. I need to collect test_density value under code_version data frame. I used several awk, sed command to fetch data, unfortunatly I cannot get the exact output from my terminal.
You need to install powerful JSON querying processor like jq processor. you can can easily install from here
once you install jq processor, try following command to extract the variable from JSON key value
suppose, your file named as server_response_123.json,
jq '.code_version.test_density' server_response_123.json
the output will be shown as,
"0.1"

Is there any good method to test restful api when response is json format?

We need wirte many MVC test to test our restful api(JAVA), and many test case are very similar: with mapping name, input body(POST method), output json.
we need verify the response json is same with expected json.
Now we just write many test case to converge distinct mapping, is there anyway to let test case more clean?
I know Junit 5 has #CsvFileSource annotation can run many tests, but it is a little weird to put json format to a csv file.
Anyone have good practice for this situation?
Based on your requirements I would suggest to have a look at Karate
you want JSON support:
JSON is a ‘first class citizen’ of the syntax such that you can express payload and expected data without having to use double-quotes and without having to enclose JSON field names in quotes
You want clean cases:
Just write tests in a simple, readable syntax - carefully designed for HTTP, JSON, GraphQL and XML.
In addition you get to work with a "BDD flavored" syntax which make tests more readable, and even understandable to non-developers.

SpringXD JSON parser to Oracle DB

I am trying to use SpringXD to stream some JSON metrics data to a Oracle database.
I am using this example from here: SpringXD Example
Http call being made: EarthquakeJsonExample
My shell cmd.
stream create earthData --definition "trigger|usgs| jdbc --columns='mag,place,time,updated,tz,url,felt,cdi,mni,alert,tsunami,status,sig,net,code,ids,souces,types,nst,dmin,rms,gap,magnitude_type' --driverClassName=driver --username=username --password --url=url --tableName=Test_Table" --deploy
I would like to capture just the properties portion of this JSON response into the given table columns. I got it to the point where it doesn't give me a error on the hashing but instead just deposits a bunch of nulls into the column.
I think my problem is the parsing of the JSON itself. Since really the properties is in the Features array. Can SpringXD distinguish this for me out of the box or will I need to write a custom processor?
Here is a look at what the database looks like after a successful cmd.
Any advice? Im new to parsing JSON in this fashion and im not really sure how to find more documentation or examples with SpringXD itself.
Here is reference to the documentation: SpringXD Doc
The transformer in the JDBC sink expects a simple document that can converted to a map of keys/values. You would need to add a transformer upstream, perhaps in your usgs processor or even a separate processor. You could use a #jsonPath expression to extract the properties key and make it the payload.

Is there a way to run MongoDB shell (or tojson method) in strict JSON mode?

Is there a way to run MongoDB shell (or particular tojson method) in strict JSON mode?
Why I need this - To be able take the output of shell (generated by some js commands followed by a tojson) and convert it to JSON objects in Java.
Alternatively,
Is there any way to parse the extended JSON from shell into java Json objects? (com.mongodb.util.JSON.parse expects strict JSON)
Workaround: you can start Mongo in REST mode and the REST mode does return strict JSON. Not sure if you can access REST through the shell but it would solve your problem.
Technically there is only strict JSON, so if the to_json() method is generating invalid JSON output then I would file a bug at https://jira.mongodb.org/secure/Dashboard.jspa
In addition, if you would give an example of what you are trying to output using to_json() then people might be able to offer you more specific help.