fixtures

How do you solve FixtureClassNotFound: No class attached to find

丶灬走出姿态 提交于 2020-01-02 01:04:14
问题 When running my tests I get this error: FixtureClassNotFound: No class attached to find What causes this error and how to fix it? 回答1: Most likely this happens because a custom table name is used for a Model (using the set_table_name) or the model is in a module. To solve, you need to add a set_fixture_class line in the test_helper.rb before the fixtures :all line: class ActiveSupport::TestCase self.use_transactional_fixtures = true . . . set_fixture_class my_table_name: MyModule::MyClass

How can I use a parametrized dependent fixture twice in pytest?

好久不见. 提交于 2019-12-31 22:35:13
问题 I'm trying to use a parametrized fixture multiple times in a single test, with the intent of getting a cartesian product of all of its values. https://stackoverflow.com/a/39444098/102441 shows how to do this for a simple fixture: import pytest @pytest.fixture(params=[0, 1, 2]) def first(request): return request.param second = first # runs 3x3 = 9 times def test_double_fixture(first, second): assert False, '{} {}'.format(first, second) However, this approach falls apart if the parametrization

Temporary Doctrine2 fixtures for testing with phpunit

南楼画角 提交于 2019-12-31 14:31:16
问题 I have an application built on Symfony2 + Doctrine2 which I want to create some tests for (using phpunit). For example if I want to test a unique validator against a record in the DB, I want to create a record I can work with, but after the test I don't need it anymore. So is there a way to create temporary (or virtual) fixtures or do I have to manually create and delete them? 回答1: You can use Doctrine DataFixture and put this code in your setUp method of a unit test class: $loader = new

Django Natural Key for Fixtures Give Deserialization Error

落爺英雄遲暮 提交于 2019-12-30 10:45:35
问题 I've seen a few similar questions to this on SO, but none seem to answer my particular problem. I'm new to Django and was guiding myself by the instructions at this page to allow myself to use natural keys to load fixtures. Nevertheless, I'm getting Deserialization errors because Django wants an integer for a foreign key and can't seem to map my natural key to an integer primary key as is noted in the instructions. Specifically, my relevant models code is: class GraphTypeManager(models

How to test the pytest fixture itself?

雨燕双飞 提交于 2019-12-30 08:40:31
问题 What is the proper way to test that the pytest fixture itself. Please do not confuse it with using fixture in tests. I want just tests the fixtures correctness by itself. When trying to call and execute them inside test I am facing: Fixture "app" called directly. Fixtures are not meant to be called directly Any input on that will be appreciated. Docs on this topic are not giving me meaningful guidance: https://docs.pytest.org/en/latest/deprecations.html#calling-fixtures-directly The

A new entity was found through the relationship *** that was not configured to cascade persist operations for entity

依然范特西╮ 提交于 2019-12-25 09:48:56
问题 I'm currently creating some fixtures for some tests and i faced this error. Have you an idea about how to solve it ? I've so many fixtures to copy paste it. A new entity was found through the relationship '***' that was not configured to cascade persist operations for entity: ***. To solve this issue: Either explicitly call EntityManager#persist() on this unknown entity or configure cascade persist this association in the mapping for example @OneToOne(..,cascade={"persist"}). If you cannot

A new entity was found through the relationship *** that was not configured to cascade persist operations for entity

谁都会走 提交于 2019-12-25 09:48:53
问题 I'm currently creating some fixtures for some tests and i faced this error. Have you an idea about how to solve it ? I've so many fixtures to copy paste it. A new entity was found through the relationship '***' that was not configured to cascade persist operations for entity: ***. To solve this issue: Either explicitly call EntityManager#persist() on this unknown entity or configure cascade persist this association in the mapping for example @OneToOne(..,cascade={"persist"}). If you cannot

how to setup database/fixture for functional tests in playframework

我们两清 提交于 2019-12-24 11:18:03
问题 I am trying to test my Controller - Secure.java. I use play's Fixtures class to setup the database. Unfortunately as the POST call is issued and the control's method is called the database turns out to be empty. However, inside the test-method I can retrieve the data as expected. The routes POST /login user.Secure.authenticate The controller Secure.java : package controllers.user; import java.io.File; import java.io.FileOutputStream; import java.io.PrintStream; import java.lang.reflect

Django unit-testing with loading fixtures for several dependent applications problems

痴心易碎 提交于 2019-12-24 10:58:02
问题 I'm now making unit-tests for already existing code. I faced the next problem: After running syncdb for creating test database, Django automatically fills several tables like django_content_type or auth_permissions. Then, imagine I need to run a complex test, like check the users registration, that will need a lof ot data tables and connections between them. If I'll try to use my whole existing database for making fixtures (that would be rather convinient for me) - I will receive the error

Selenium: How do I use javascript to clear a value from a form field?

心已入冬 提交于 2019-12-24 05:37:26
问题 I'm using the selenium IDE and the Selenium-Fitnesse Bridge fixture and I'm trying to test that when I clear a default value out of a form field, my form displays an error message. So when I record with the Selenium IDE, what it does is the equivalent of telling Selenium to type nothing. | type | text_field | | The problem with this is that the Fitnesse fixture I'm using expects that second argument to not be null. Is there a way in Selenium to "clear a value" rather than "typing nothing"?