Create a Continuous Integration Server
- install TeamCity
- install Ruby
- install Albacore
Have a rake script do the following
1. check out files from source control
2. build locally
3. deploy api to local iis
4. run integration tests against localhost api
This started to sound familiar. See here
Here is an example from my API integration tests. Let me know if you want more details.
I am using mspec.
I run it aganst localhost, our staging server, and our production server (a limited set of tests) to make sure all http connections are working.
public class _GET_no_criteria : specs_for_endpoint_test
{
Establish context = () =>
{
Uri = C.Endpoint;
Querystring = "";
ExecuteJsonGetRequest();
SetValidId();
};
It should_have_status_code_200_ok =()=>
IsHttp_200OK();
It should_have_categories = () =>
{
responseText.ShouldNotBeEmpty();
PutsAll(responseText);
};
}
From the base class
public static void ExecuteGetRequest(string contentType)
{
httpcontext = HttpContext.Current;
request = (HttpWebRequest)WebRequest.Create(BaseUri + Uri + Querystring);
request.Method = C.HTTP_GET;
request.ContentType = contentType;
request.Headers[C.AUTHORIZATION] = token;
// GetResponse reaises an exception on http status code 400
// We can pull response out of the exception and continue on our way
try
{
response = (HttpWebResponse)request.GetResponse();
}
catch (WebException ex)
{
response = (HttpWebResponse) ex.Response;
}
using (StreamReader reader = new StreamReader(response.GetResponseStream()))
{
responseText = reader.ReadToEnd();
reader.Close();
}
}
public static void ExecuteJsonGetRequest()
{
ExecuteGetRequest(C.CONTENT_JSON);
}