Отчеты JUnit — описания метода тестирования

Попробуйте следующий код с вашим ключом API ... если он не работает, то ваш ключ, вероятно, признан недействительным.

import json
import urllib
import urllib.parse
import urllib.request

queries = [
    {'mpn': 'SN74S74N',
     'reference': 'line1'},
    {'sku': '67K1122',
     'reference': 'line2'},
    {'mpn_or_sku': 'SN74S74N',
     'reference': 'line3'},
    {'brand': 'Texas Instruments',
     'mpn': 'SN74S74N',
     'reference': 'line4'}
    ]

url = 'http://octopart.com/api/v3/parts/match?queries=%s' \
    % urllib.parse.quote(json.dumps(queries))
url += "&include[]=specs"

# NOTE: Use your API key here (https://octopart.com/api/register)
url += '&apikey=<REPLACEME>'

data = urllib.request.urlopen(url).read()
response = json.loads(data)

# print request time (in milliseconds)
print("Response time: %s msec\n" % response['msec'])
24
задан guerda 22 April 2009 в 10:51
поделиться

2 ответа

Я не помещаю javadoc в тесты JUnit. Я обычно делаю название метода достаточно наглядным, чтобы оно было лучше или лучше любого комментария, который я мог придумать.

6
ответ дан 29 November 2019 в 00:16
поделиться

Я мог бы представить, что Framework для интегрированных тестов (FIT) было бы хорошим и чистым решением.

Что делает FIT?
FIT - это среда, которая позволяет писать тесты с помощью таблицы в документе Word, вики-таблицы или HTML-таблицы.
Every character outside of a table is ignored by FIT and let you enter documentation, description, requirements and so on.

How does on of these tables look like?

Imagine a function MyMath.square(int) that squares it's input parameter. You have to build a so called Fixture, being an adapter between your MyMath and the following table:

class.with.Fixture.Square
x    square()
2    4
5    25

The first column describes input values, the second the expected result. If it's not equal, this field is marked as red.

How does a Fixture look like?
For the given example, this would be the correct fixture:

package class.with.Fixture // Must be the same as in the fist row of the table

public class Square extends Fixture {
    public int x; // Must be the same as in the second row
    public int square() { // Must be the same as in the second row
        return MyMath.square(x);
    }
}

Probably, you can use FIT for your requirements.
Feel free to comment my answer or edit your question for more information!

-1
ответ дан 29 November 2019 в 00:16
поделиться
Другие вопросы по тегам:

Похожие вопросы: