or run

npx @tessl/cli init
Log in

Version

Tile

Overview

Evals

Files

Files

docs

data-models.mdindex.mdplugin-system.mdtest-decorators.mdtest-lifecycle.mdutilities.md

data-models.mddocs/

0

# Data Models

1

2

Complete set of data structures for representing Allure test results, containers, attachments, and metadata. These classes provide the object model for all Allure test data with proper serialization support for JSON output.

3

4

## Capabilities

5

6

### Core Test Result Classes

7

8

Main classes representing test execution results and their hierarchical organization.

9

10

```python { .api }

11

class TestResult(ExecutableItem):

12

"""

13

Represents a single test case result.

14

15

Attributes:

16

- uuid (str): Unique identifier for the test

17

- historyId (str): Identifier for test history tracking

18

- testCaseId (str): Test case identifier from external system

19

- fullName (str): Full qualified test name

20

- labels (List[Label]): List of test labels

21

- links (List[Link]): List of external links

22

- titlePath (List[str]): Hierarchical title path

23

"""

24

25

# Pattern for JSON file naming

26

file_pattern = TEST_CASE_PATTERN

27

28

class TestResultContainer:

29

"""

30

Container for grouping related test results and fixtures.

31

32

Attributes:

33

- uuid (str): Unique identifier for the container

34

- name (str): Container display name

35

- children (List[str]): List of child test UUIDs

36

- description (str): Container description

37

- descriptionHtml (str): HTML formatted description

38

- befores (List[TestBeforeResult]): Before fixtures

39

- afters (List[TestAfterResult]): After fixtures

40

- links (List[Link]): List of external links

41

- start (int): Start timestamp in milliseconds

42

- stop (int): Stop timestamp in milliseconds

43

"""

44

45

# Pattern for JSON file naming

46

file_pattern = TEST_GROUP_PATTERN

47

```

48

49

### Executable Item Hierarchy

50

51

Base classes for items that can be executed and contain steps, attachments, and parameters.

52

53

```python { .api }

54

class ExecutableItem:

55

"""

56

Base class for executable test items.

57

58

Attributes:

59

- name (str): Item display name

60

- status (str): Execution status (from Status constants)

61

- statusDetails (StatusDetails): Detailed status information

62

- stage (str): Execution stage

63

- description (str): Item description

64

- descriptionHtml (str): HTML formatted description

65

- steps (List[TestStepResult]): List of execution steps

66

- attachments (List[Attachment]): List of attached files/data

67

- parameters (List[Parameter]): List of test parameters

68

- start (int): Start timestamp in milliseconds

69

- stop (int): Stop timestamp in milliseconds

70

"""

71

72

class TestStepResult(ExecutableItem):

73

"""

74

Represents a single test step result.

75

76

Attributes:

77

- id (str): Step identifier

78

"""

79

80

class TestBeforeResult(ExecutableItem):

81

"""Represents a before fixture execution result."""

82

83

class TestAfterResult(ExecutableItem):

84

"""Represents an after fixture execution result."""

85

```

86

87

### Metadata and Supporting Classes

88

89

Classes for representing test metadata, parameters, labels, and links.

90

91

```python { .api }

92

class Parameter:

93

"""

94

Represents a test parameter.

95

96

Attributes:

97

- name (str): Parameter name

98

- value (str): Parameter value (stringified)

99

- excluded (bool): Whether parameter should be excluded from display

100

- mode (ParameterMode): Display mode for the parameter

101

"""

102

103

class Label:

104

"""

105

Represents a test label for categorization and filtering.

106

107

Attributes:

108

- name (str): Label name/type

109

- value (str): Label value

110

"""

111

112

class Link:

113

"""

114

Represents an external link associated with a test.

115

116

Attributes:

117

- type (str): Link type (from LinkType constants)

118

- url (str): Link URL

119

- name (str): Display name for the link

120

"""

121

122

class StatusDetails:

123

"""

124

Detailed information about test execution status.

125

126

Attributes:

127

- known (bool): Whether this is a known issue

128

- flaky (bool): Whether this test is flaky

129

- message (str): Status message

130

- trace (str): Exception stack trace

131

"""

132

133

class Attachment:

134

"""

135

Represents a file or data attachment.

136

137

Attributes:

138

- name (str): Display name for attachment

139

- source (str): File path or identifier

140

- type (str): MIME type of the attachment

141

"""

142

```

143

144

### Status and Type Constants

145

146

Constants defining valid values for various status and type fields.

147

148

```python { .api }

149

class Status:

150

"""Test execution status constants."""

151

FAILED = 'failed'

152

BROKEN = 'broken'

153

PASSED = 'passed'

154

SKIPPED = 'skipped'

155

UNKNOWN = 'unknown'

156

157

class ParameterMode(Enum):

158

"""Parameter display modes."""

159

HIDDEN = 'hidden' # Parameter hidden from display

160

MASKED = 'masked' # Parameter value masked (e.g., passwords)

161

DEFAULT = None # Default parameter display

162

163

class AttachmentType(Enum):

164

"""

165

Attachment MIME types with corresponding file extensions.

166

167

Each enum value contains (mime_type, extension) tuple.

168

"""

169

170

# Text formats

171

TEXT = ("text/plain", "txt")

172

CSV = ("text/csv", "csv")

173

TSV = ("text/tab-separated-values", "tsv")

174

URI_LIST = ("text/uri-list", "uri")

175

176

# Structured data formats

177

HTML = ("text/html", "html")

178

XML = ("application/xml", "xml")

179

JSON = ("application/json", "json")

180

YAML = ("application/yaml", "yaml")

181

PCAP = ("application/vnd.tcpdump.pcap", "pcap")

182

183

# Image formats

184

PNG = ("image/png", "png")

185

JPG = ("image/jpg", "jpg")

186

SVG = ("image/svg+xml", "svg")

187

GIF = ("image/gif", "gif")

188

BMP = ("image/bmp", "bmp")

189

TIFF = ("image/tiff", "tiff")

190

191

# Video formats

192

MP4 = ("video/mp4", "mp4")

193

OGG = ("video/ogg", "ogg")

194

WEBM = ("video/webm", "webm")

195

196

# Document formats

197

PDF = ("application/pdf", "pdf")

198

```

199

200

### File Naming Patterns

201

202

Constants defining file naming patterns for different result types.

203

204

```python { .api }

205

# File naming patterns

206

TEST_GROUP_PATTERN = "{prefix}-container.json" # Container files

207

TEST_CASE_PATTERN = "{prefix}-result.json" # Test result files

208

ATTACHMENT_PATTERN = '{prefix}-attachment.{ext}' # Attachment files

209

210

# JSON formatting

211

INDENT = 4 # Indentation level for JSON output

212

```

213

214

## Usage Examples

215

216

### Creating Test Results

217

218

```python

219

from allure_commons.model2 import (

220

TestResult, TestResultContainer, Label, Link, Parameter,

221

Status, AttachmentType

222

)

223

224

# Create a test result

225

test_result = TestResult()

226

test_result.uuid = "test-123"

227

test_result.name = "User Login Test"

228

test_result.fullName = "tests.auth.test_login.test_user_login"

229

test_result.status = Status.PASSED

230

test_result.start = 1609459200000 # timestamp

231

test_result.stop = 1609459205000 # timestamp

232

233

# Add labels

234

severity_label = Label()

235

severity_label.name = "severity"

236

severity_label.value = "critical"

237

test_result.labels.append(severity_label)

238

239

feature_label = Label()

240

feature_label.name = "feature"

241

feature_label.value = "Authentication"

242

test_result.labels.append(feature_label)

243

244

# Add links

245

bug_link = Link()

246

bug_link.type = "issue"

247

bug_link.url = "https://jira.company.com/BUG-123"

248

bug_link.name = "Related Bug"

249

test_result.links.append(bug_link)

250

251

# Add parameters

252

username_param = Parameter()

253

username_param.name = "username"

254

username_param.value = "testuser"

255

test_result.parameters.append(username_param)

256

257

password_param = Parameter()

258

password_param.name = "password"

259

password_param.value = "***"

260

password_param.mode = ParameterMode.MASKED

261

test_result.parameters.append(password_param)

262

```

263

264

### Creating Containers and Fixtures

265

266

```python

267

from allure_commons.model2 import (

268

TestResultContainer, TestBeforeResult, TestAfterResult

269

)

270

271

# Create a container for grouping tests

272

container = TestResultContainer()

273

container.uuid = "container-456"

274

container.name = "Authentication Test Suite"

275

container.start = 1609459180000

276

container.children = ["test-123", "test-124", "test-125"]

277

278

# Add before fixture

279

setup_fixture = TestBeforeResult()

280

setup_fixture.name = "setup_test_database"

281

setup_fixture.status = Status.PASSED

282

setup_fixture.start = 1609459185000

283

setup_fixture.stop = 1609459190000

284

container.befores.append(setup_fixture)

285

286

# Add after fixture

287

cleanup_fixture = TestAfterResult()

288

cleanup_fixture.name = "cleanup_test_data"

289

cleanup_fixture.status = Status.PASSED

290

cleanup_fixture.start = 1609459300000

291

cleanup_fixture.stop = 1609459305000

292

container.afters.append(cleanup_fixture)

293

```

294

295

### Working with Attachments

296

297

```python

298

from allure_commons.model2 import Attachment, AttachmentType

299

300

# Create text attachment

301

log_attachment = Attachment()

302

log_attachment.name = "Test Execution Log"

303

log_attachment.source = "abc123-attachment.txt"

304

log_attachment.type = AttachmentType.TEXT.mime_type

305

306

# Create screenshot attachment

307

screenshot_attachment = Attachment()

308

screenshot_attachment.name = "Failure Screenshot"

309

screenshot_attachment.source = "def456-attachment.png"

310

screenshot_attachment.type = AttachmentType.PNG.mime_type

311

312

# Add to test result

313

test_result.attachments.extend([log_attachment, screenshot_attachment])

314

```

315

316

### Status Details and Error Handling

317

318

```python

319

from allure_commons.model2 import StatusDetails

320

321

# Create detailed status for failed test

322

status_details = StatusDetails()

323

status_details.known = False

324

status_details.flaky = True

325

status_details.message = "Connection timeout after 30 seconds"

326

status_details.trace = """

327

Traceback (most recent call last):

328

File "test_api.py", line 42, in test_connection

329

response = requests.get(url, timeout=30)

330

requests.exceptions.Timeout: Connection timeout

331

"""

332

333

# Add to test result

334

failed_test = TestResult()

335

failed_test.status = Status.FAILED

336

failed_test.statusDetails = status_details

337

```