lamchakchan / restassured.net Goto Github PK
View Code? Open in Web Editor NEWA simple testing suite for REST based interfaces
License: Apache License 2.0
A simple testing suite for REST based interfaces
License: Apache License 2.0
How do I set a cookie?
There is a problem with Debug throwing exception when Then.Load() is not called.
Suppose we have response json like below, we want to get complete json to deserialize into dictionary(collection) inorder to verify from database but .Retrieve(x=> x) is crashing.
{
"customerId": "12345",
"title": "GitHub",
"Address": {
"City": "NYC",
"Zip": "11223344"
},
"alias": {
"type": "ContactNumber",
"value": "12345678910"
},
"Membership": "Individual"
}
Add a Query() function like Param() to feed key/value pairs. Currently, Param is overloaded and we want more intent. Param feeds into the body and Query feeds to the query string.
Hi,
I'm trying to perform multiple assertions with TestStatus and TestBody without schema validation. From what I have observed AssertAll()
always validates schema, which I think it should not be.
Below test is present in MockResponseContextWithJson.cs
[Test]
public void AllowMultipleWithoutSchemaAssertion()
{
_responseWithObject
.TestStatus("first", code => code == 200)
.TestBody("second", body => body.id != null)
.AssertAll();
}
(Based on name of this test I assume AssertAll() performs multiple assertions without schema assertion)
When we have a sample test with below assertions
.TestStatus("first", code => code == 200)
.TestBody("second", body => body.id != null)
.WriteAssertions()
.AssertAll();
Output shows that schema assertion is always perfromed as part of AssertAll().
Can anyone please correct me if I am wrong and let me know how to bypass schema validation as part of AssertAll()?
Thank you!
Thanks for this project. I sent an email, but no answer, so turning to the community.
I have some questions about it. Is it actively maintained? Is it designed to keep up with all features of the Java version, or does it go its own way? Is it a must when testing a .NET API, or is it possible to integrate the Java version too? I'm thinking about things like creation and destruction of the test database.
Is it possible to send authorization bearer token ?
Should it go on Header or as Param ? Thanks.
I used three TestBody(), and asserting it via AssertAll(), getting Schema Check Failed Exception.
Hello,
I need to ignore the ssl certificate errors, how can I do it in restassured?
When both content and schema are valid, the schema assertion fails
When I write unit test to download a file .jpg, Rest Assurured throw System.Exception: (image/jpeg) not supported. How I can write unit test to download file excel or image with Rest Assured? Thanks for helping
Some of our tests give response in plain text format and this format is not included in 'Parse()' function.
Parse() function only supports 'json' and 'xml'. Please add support of 'text/plain'. Thanks.
In REST it's common to have query string params with same name, to get multiple values added to 1 variable, example:
myservice.com?param=value1¶m=value2
But with RestAssured.Net the .Query(key, value) method is using Dictionary and adds only 1st query param with that name, others are ignored.
Please implement support for providing multiple values.
Possible syntax:
.Query("param", "value1").Query("param", "value2")
OR
.Query("param", "value1", "value2")
Currently the ContentDispositionHeaderValue for a file is always set as "attachment". We would rather see "form-data" instead here for our case. Would you be so kind as to provide a switch for configuring the file upload mode? Thanks!
I want to use RestAssured.Net to write tests for my .net core application but it is yet not compatible. Is this something we can expect in near future?
parse() method is failed to parse if the JSON response is "2.3.3". it's rising unsupported contenttype
Hi,
Recently, I have tried integrating specflow with restassured, however it seems that there are some threading issue, when a step definition is being executed the thread where restassured gets executed is different from the step defintion thread, therefore the restassured request will never complete and will keeps looping forever.
When executing restassured request using normal unit test framework, it works fine as it shares the same thread as the test execution.
Any one experiencing this issue before? or workaround?
Hi all,
Is it possible to pass a HttpClient instance to the SetupContext in order to use TestServer middleware?
Something like this:
_testServer = new TestServer(new WebHostBuilder()
.UseStartup<Startup>()
_httpClient = _testServer.CreateClient();
public void MyTest()
{
var test= new RestAssured()
.Given()
.HttpClient(_httpClient)
Thx
I am using the library, however it is not clear in the documentation which is nameSapace that must be imported in the using to be able to use the library in my class.
Getting "Could not install package 'RestAssured 1.0.0'. You are trying to install this package into a project that targets '.NETFramework,Version=v4.5.2', but the package does not contain any assembly references or content files that are compatible with that framework. For more information, contact the package author." error when trying to install RestAssured 1.0.0
I require the ability to submit binary files as part of a request body for testing.
I can't use .File() because this converts the request to a multipart/form - which my server does not expect.
The current implementation of Body() in RA/src/SetupContext.cs line 159 uses JsonConvert.Deserialize() but I need a way to prevent it from converting everything to json and use the correct serializer for whatever I pass in.
@DayneD89 - I know you're working on this at the moment, could you possibly look into this?
Thanks.
var endpoint1 = new RestAssured()
.Given()
//Optional, set the name of this suite
.Name("JsonIP Test Suite")
//Optional, set the header parameters.
//Defaults will be set to application/json if none is given
.Header("Content-Type", "application/json")
.Header("Accept-Encoding", "gzip,deflate")
.Host("jsonip.com")
.Uri("/endpoint1");
endpoint1.When().Get().Then().TestBody("test 1", x => x.ip != null).Assert("test 1");
is not compiling and giving me error System.Exception : (application/json; charset=utf-8) not supported
Same for the below modified code from example:
var endpoint1 = new RestAssured()
.Given()
//Optional, set the name of this suite
.Name("JsonIP Test Suite")
//Optional, set the header parameters.
//Defaults will be set to application/json if none is given
.Header("Content-Type", "application/json")
.Header("Accept-Encoding", "gzip,deflate")
.Host("jsonip.com")
.Uri("/endpoint1");
//Make a copy of the settings from above, but adjust the endpoint.
var endpoint2 = endpoint1.Clone().Uri("/endpoint2");
//Do a GET action with the first endpoint configuration
endpoint2.When().Get().Then().TestBody("test 1", x => x.id != null).Assert("test 1");
//Do a POST action with the second endpoint configuration
endpoint2.When().Post().Then().TestBody("test 1", x => x.id != null).Assert("test 1");
For some reason, I am unable to hit a localhost address. To replicate this I am hosting http://jsonplaceholder.typicode.com/ locally on port 3000 and I can confirm that accessing this url through a web browser brings up the same information as using the site. For this example I'll be using the path /todos/1/.
int type = 2;
string uhost = (type == 1)
? "https://jsonplaceholder.typicode.com"
: "http://localhost";
new RestAssured()
.Given()
.Name("Localhost Test")
.Port((type == 1) ? 80 : 3000)
.When()
.Get(uhost+"/todos/1")
.Then()
.TestStatus("test a", x => x == 200)
.Assert("test a")
.WriteAssertions();
When type is 1 this runs as expected, however, when I change it to 2 (localhost) it gets back a HTML page and a 404 (Thus it fails to parse as Content-Type is html, but I set a custom parser to just print the _content to the console for this content-type).
Localhost does work if I change this to;
new RestAssured()
.Given()
.Name("Localhost Test")
.Port((type == 1) ? 80 : 3000)
.Host(uhost)
.When()
.Get("/todos/1")
.Then()
.TestStatus("test a", x => x == 200)
.Assert("test a")
.WriteAssertions();```
However, needing a workaround isn't elegant.
Doesn't seem to work with response types that are not application/json?
E.g. for returning a text/html or application/vnd.ms-excel, etc
Are there plans to add support, or is this project abandoned?
Hi ,
I need to access Restassured dll in my application, can you give me step by step sample application?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.