Questions tagged [test-fixture]

Fixtures seems to be mostly a term used within UI Test automation, and carries a similar meaning to test-context or test-plans. Fixture categorizes the test cases that logically belong to a related scenario, such as Login screen tests, Load database with master data, etc. Also with test-fixtures it ensures that tests are run under a fixed environment where the test runs are done and the results are repeatable.

Fixtures seems to be mostly a term used within UI Test automation, and carries a similar meaning to test-context or test-plans. Fixture categorizes the test cases that logically belong to a related scenario, such as Login screen tests, Load database with master data, etc. Also with test-fixtures it ensures that tests are run under a fixed environment where the test runs are done and the results are repeatable.

For more details follow one of the online documentation found via the JUnit and Xamarin.UITests and Wikipedia in following links.

17 questions
337
votes
6 answers

What are fixtures in programming?

I have heard of this term many times (in the context of programming) but couldn't find any explanation of what it meant. Any good articles or explanations?
Matjaz Muhic
  • 5,328
  • 2
  • 16
  • 34
174
votes
7 answers

Run code before and after each test in py.test?

I want to run additional setup and teardown checks before and after each test in my test suite. I've looked at fixtures but not sure on whether they are the correct approach. I need to run the setup code prior to each test and I need to run the…
edA-qa mort-ora-y
  • 30,295
  • 39
  • 137
  • 267
23
votes
2 answers

Google Test Fixtures

I'm trying to understand how the Google Test Fixtures work. Say I have the following code: class PhraseTest : public ::testing::Test { protected: virtual void SetUp() { phraseClass * myPhrase1 = new…
bei
  • 933
  • 3
  • 9
  • 17
17
votes
1 answer

How do I write SQLAlchemy test fixtures for FastAPI applications

I am writing a FastAPI application that uses a SQLAlchemy database. I have copied the example from the FastAPI documentation, simplifying the database schema for concisions' sake. The complete source is at the bottom of this post. This works. I can…
W.P. McNeill
  • 16,336
  • 12
  • 75
  • 111
6
votes
3 answers

pytest - How to execute a function after specific tests

I have some tests organized in several classes. I already have a test fixture with scope=class so that it would run before suite(class) of tests. However, I need to execute a function after some specific tests. Lets say I have 100 tests in a class,…
Override12
  • 116
  • 1
  • 7
3
votes
1 answer

gradle integrationTest and testFixtures

I'm using gradle 7.4.2 so I decided to split the tests to proper unit-test and integration-tests. I moved one class from src/test/java/com/example to src/integrationTest/java/com/example, and started to add the missing dependencies. The problem is…
Gavriel
  • 18,880
  • 12
  • 68
  • 105
1
vote
2 answers

Pytest missing 1 required positional argument with fixture

I'm using vscode as IDE I have code a very simple usage of pytest fixture but it doesn't working when basic example fixture found in the pytest documentation are working well : @pytest.fixture def declare_hexidict(): hd = hexidict() rvc =…
Chrys Bltr
  • 68
  • 3
  • 13
1
vote
2 answers

NUnit C# Generic Class Test Fixtures with constructor arguments in the class under test

I have a bunch of classes implementing an interface and having a constructor argument. For this classes i want to write a test with Generic Test Fixture pattern as documented in the nunit docs section:…
Daimonion
  • 94
  • 8
1
vote
0 answers

Enforce Model validations on test Fixtures AND/OR seed data as test data

I write auto-mated mini-test for my Rails app and sometimes it costs me an hour just to trace why my test failed while my manual test using Postman not. (Test vs Dev DB) The problem turned out to be my test fixtures (YML) did not get validated and…
0
votes
0 answers

Why does Visual Studio Code debugger fail to start with a parameterized NUnit TestFixture in C#?

When I debug my parametrized TestFixture in VSCode .NET Testm the logs show this exception: NUnit Adapter 4.4.0.0: Test discovery starting NUnit Adapter 4.4.0.0: Test discovery complete System.ArgumentException: Selected argument cannot be empty.…
Marty
  • 1
0
votes
0 answers

How to extend test from jest fixtures for running playwright test?

I want to write some tests using jest and use some more capabilities using test fixtures. // tests/sample.test.ts jest.setTimeout(60 * 1000); import { test } from './jest-fixture'; import { chromium } from 'playwright'; describe("Sample test", ()…
0
votes
0 answers

is there any way to pass the instance of the target blank page in fixture in playwright

Im trying to perform a end to end test on a e-commerce website using playwright with TS (POM ,Fixture) while performing the test im using POM and fixture concept . The problem is that im while performing the test the product description page open on…
0
votes
1 answer

How do I write json value using variable in cypress

it ('check link', () => { cy.visit(/) var link1_value var link2_value var datasheet_value cy.get('[class="classname"]').then(($link1) => { if ($link1.find('[data-type="link1"]').length>0){ …
Pb An
  • 25
  • 4
0
votes
1 answer

NUnit: How to start a test only with one userRole, while there are 3 different userRoles defined in TestFixture

I have a "Regression Test" Class in which i defined 3 different user Roles in the TestFixture In the regression test i'm testing other web app functionalities beside of the main feature functionalities. Currently im having there 5 different tests…
Beardy
  • 163
  • 1
  • 15
0
votes
1 answer

gradle testFixturesImplementation cannot find symbol Mockito

I am trying to set up testFixtures. I have a class that until now was in src/test/ and now I'm trying to turn it into fixrure. In build.gradle I added: plugins { id 'java-library' id "java-test-fixtures" } I moved the class from…
Gavriel
  • 18,880
  • 12
  • 68
  • 105
1
2