Skip to content

Commit

Permalink
Fix typos
Browse files Browse the repository at this point in the history
  • Loading branch information
koppor committed Mar 16, 2018
1 parent 8cc07d5 commit d90a290
Showing 1 changed file with 64 additions and 46 deletions.
110 changes: 64 additions & 46 deletions docs/dev/howtoTestRepository.md
Original file line number Diff line number Diff line change
@@ -1,70 +1,82 @@
# Howto Test (in Winery Repository)
In this document the way how tests for the Winery Repository are implemented based on real implemented Example. The Example is Implemented in the Last Chapter its a simple implementation of the `NodeTypeImplementationResourceTest`.
In this document the way how tests for the Winery Repository are implemented based on a real implemented example.
The example is is a simple implementation of the `NodeTypeImplementationResourceTest`.

This test covers the `GET` Responses to the client created by the backend implementations, based on the Winery Test Repository.

This test will cover the GET Responses to the Client created by the Backend Implementations, based on the Winery Test Repository.
## Preparations

## Preparations
In this chapter we will cover how to get the right information to prepare a Test.
Here, we cover how to get the right information to prepare a test.

### Find class to Test

First of all you should find a Class to test, where you know the logic behind.
If you follow this example, you will test the Response generated by the backend against a local File you created, it will contain the Response we are expecting.
If you follow this example, you will test the Response generated by the backend against a local file you created, it will contain the response we are expecting.

### Download the Winery Test Repository
Based on the Winery test Repository the Responses will be created from the backend. Its available under [Winery Quickstart](http://eclipse.github.io/winery/user/#quickstart)
Based on the Winery test repository the responses will be created from the backend.
It is available under [Winery Quickstart](http://eclipse.github.io/winery/user/#quickstart)

#### Windows

You will have to check out the Winery repository to `C:\Winery-Repository`
That means you will navigate to your C-Directory with an CMD or Powershell. After that you clone `https://github.com/winery/test-repository.git`
You will have to check out the Winery repository to `C:\winery-repository`
That means you will navigate to your C directory with an CMD or Powershell.
After that you clone `https://github.com/winery/test-repository.git`

`git clone https://github.com/winery/test-repository.git C:\winery-repository`
git clone https://github.com/winery/test-repository.git C:\winery-repository

Now we have the most recent of the winery repository test data.

#### Unix,Mac,Ubuntu etc.
#### Unix, Mac, Ubuntu, etc.

You will have to check out the Winery repository to `~\Winery-Repository`
That means you will navigate to your Homedirectory with a terminal or your favourite shell. After that you clone `https://github.com/winery/test-repository.git`
You will have to check out the Winery repository to `~\winery-repository`
That means you will navigate to your home directory with a terminal or your favourite shell.
After that you clone `https://github.com/winery/test-repository.git`

`git clone https://github.com/winery/test-repository.git ~/winery-repository`
git clone https://github.com/winery/test-repository.git ~/winery-repository

Now we have the most recent of the Winery repository test data.

### How to get the Right Commit ID for your Test
If you write a new Test you should always base it on the last commit, if you add Files use that commit.
If you want to know which is the latest commit id right now you should get the SHA1 Commit Id.
### How to get the right commit ID for your test

**Update:** A branch name is preferred.
See <https://winery.github.io/test-repository/> for an explanation of the branches.

<s>
If you write a new test you should always base it on the last commit, if you add files use that commit.
If you want to know which is the latest commit id right now you should get the SHA1 commit Id.

To get it from your checkout just follow these Steps:

- Go to the Github Site [Commit overview](https://github.com/winery/test-repository/commits/black)
- Go to the Github site [Commit overview](https://github.com/winery/test-repository/commits/black)
- Choose your commit and look at the right side - you will see a short code like `88e5ccd`
- Click on the Commit code you want to see
- On the Right Side you will see the full Commit ID, it starts with the same as the link you clicked before, in this case `88e5ccd6c35aeffdebc19c8dda9cd76f432538f8` (`gitk` can be used, too).

- Click on the commit code you want to see
- On the right side you will see the full commit ID, it starts with the same as the link you clicked before, in this case `88e5ccd6c35aeffdebc19c8dda9cd76f432538f8` (`gitk` can be used, too).
</s>


## Create a new Test
In this chapter we will cover the notation and the Paths you should place the Test Classes you create.
## Create a new test
In this section, we will cover the notation and the Paths you should place the test classes you create.

### Create a Test Class
If you want to Test the Class `NodeTypeResource` in the Package `org.eclpse.winery.repository.resources.entitytypes.nodetypes`.
That means we need to create a respective package in the Test Folder of the Project.
### Create a test class
If you want to test the class `NodeTypeResource` in the package `org.eclpse.winery.repository.resources.entitytypes.nodetypes`.
That means we need to create a respective package in the test folder of the project.

We create a new Class for the `NodeTypeResource` Test which we name `NodeTypeResourceTest` in the Package `org.eclipse.winery.repository.resources.entitytypes.nodetypes` in the Test Folder located under src/test`
We create a new Class for the `NodeTypeResource` Test which we name `NodeTypeResourceTest` in the package `org.eclipse.winery.repository.resources.entitytypes.nodetypes` in the test Folder located under `src/test`.

Now that we are Testing a Resource Class we have to add `extends AbstractResourceTest` to the Class definition, this will help us simplifying the Test Classes and only put the tests them self in there.
Now that we are testing a resource class we have to add `extends AbstractResourceTest` to the class definition, this will help us simplifying the Test Classes and only put the tests them self in there.


## Add Test Methods

For basic testing in the repository, we created two Testcases for each type.
```
For basic testing in the repository, we created two test cases for each type.

```java
@Test
public void getInstanceXml() throws Exception {
// Getting Xml from a API, checking if its equal to the expected local file.
}

@Test
public void getServicetemplate() throws Exception {
// Getting JSON from a API, checking if its equal to the expected local file.
Expand All @@ -73,41 +85,46 @@ For basic testing in the repository, we created two Testcases for each type.

These are the two basic methods to test the capability of the API, to serve JSON and XML mime types as response.

## Things to prepare on Test
## Things to prepare on test

Before running the Basic Test logic like in the Chapter [Add Test Methods](##Add Test Methods)
you have to get a Github commit-id from the [Test-Repository](https://github.com/winery/test-repository).

In the following example is shown how to get a revision:
```

```java
@Test
public void getServicetemplate() throws Exception {
this.setRevisionTo("c25aa724201824fce6eddcc7c35a666c6e015880");
// Test Logic
}
```
## Implement a Testing Logic

To Test the Logic you can simply implement this two liner Test, it will check out the Revision `c25aa724201824fce6eddcc7c35a666c6e015880` from Github Repository located under [Test-Repository](https://github.com/winery/test-repository).
Afterwards it will send a GET request against the Backend initialized by the GIT-Repository Data. The Response will be tested for equality against a File with the expected Result.
## Implement a testing logic

To test the logic you can simply implement this two liner test, it will check out the revision `c25aa724201824fce6eddcc7c35a666c6e015880` from GitHub repository located at <https://github.com/winery/test-repository>.
Afterwards it will send a GET request against the backend initialized by the GIT repository data.
The response will be tested for equality against a file with the expected result.

If the result is equal the test will become marked as successful.

If the Result is equal the Test will become marked as successful.
```
@Test
public void getInstanceXml() throws Exception {
this.setRevisionTo("c25aa724201824fce6eddcc7c35a666c6e015880");
this.assertGet(INSTANCE_URL, INSTANCE_LOCAL_PATH);
}
```
## Run a Test or Test Class

If you want to run a Test you can simply Run it from Menu in your Eclipse or IntelliJ IDE.
## Run a test or test class

## Appendix
If you want to run a test you can simply run it from menu in your IDE.

Here we have a simple implementation of the `NodeTypeImplementationResourceTest`.
````
## Appendix

Here we have a simple implementation of the `NodeTypeImplementationResourceTest`.

```java
package org.eclipse.winery.repository.resources.entitytypeimplementations.nodetypeimplementations;

import org.eclipse.winery.repository.resources.AbstractResourceTest;
Expand Down Expand Up @@ -140,11 +157,12 @@ public class NodeTypeImplementationResourceTest extends AbstractResourceTest {

## License

Copyright (c) 2013-2017 University of Stuttgart.
Copyright (c) 2017-2018 Contributors to the Eclipse Foundation

All rights reserved. This program and the accompanying materials
are made available under the terms of the [Eclipse Public License v2.0]
and the [Apache License v2.0] which both accompany this distribution.
See the NOTICE file(s) distributed with this work for additional
information regarding copyright ownership.

[Apache License v2.0]: http://www.apache.org/licenses/LICENSE-2.0.html
[Eclipse Public License v2.0]: http://www.eclipse.org/legal/epl-v20.html
This program and the accompanying materials are made available under the
terms of the Eclipse Public License 2.0 which is available at
http://www.eclipse.org/legal/epl-2.0, or the Apache Software License 2.0
which is available at https://www.apache.org/licenses/LICENSE-2.0.

0 comments on commit d90a290

Please sign in to comment.