Questions tagged [unit-tests]

Denotes questions related to unit testing on Magento.

22 questions with no upvoted or accepted answers
Filter by
Sorted by
Tagged with
10
votes
0answers
90 views

Magento2 Chrome Driver Service error in MTF

I am new to MTF. I have followed the magento2 tutorial based on the following link But When I am running the command vendor/bin/phpunit I am getting the following error - Fatal error: Uncaught ...
4
votes
1answer
128 views

Class 'Magento\TestFramework\TestCase\AbstractController' not found when running unit test for custom module

I tried to make a unit test for my custom module like this: app/code/MyCompany/UnitTest/Test/Unit/Controller/SpinTest.php namespace MyCompany\UnitTest\Controller; class SpinTest extends \Magento\...
4
votes
0answers
123 views

Unit testing ina Magento 2 - Mocks and Assertions

Open file \Magento\Cms\Test\Unit\Model\PageRepositoryTest and take a look at the setUp() method /** * Initialize repository */ protected function setUp() { $this->pageResource = $this->...
4
votes
1answer
517 views

How to use collection factory model in Unit Test magento 2

I have a custom extension with model with structure like this in database: +----------------------------------+ |entity_id | customer_id | balance | +----------------------------------+ | 1 | ...
3
votes
0answers
86 views

Cart observer unit testing

I created a module that has some logic to modify the price of certain items depending on a few conditions pertaining to the other items in the cart. I'm trying to write a unit test to test that the ...
2
votes
0answers
67 views

How to post form data from Unit Test controller to custom controller | Magento 2

I have a custom module with form. I want to post values from unit test file to my custom module controller. I tried $this->request = $this->getMockBuilder(\Magento\Framework\App\RequestInterface::...
2
votes
0answers
43 views

What is the correct way to create Mock input interface in Web-Api functional test?

I've already write successfully a Web-Api unit test for a Custom API. But I'm wondering if there is a way to automatically create a Mock for input data for the API? For example, AccountManagement ...
2
votes
0answers
69 views

Unit Testing With Magento 2

Where should i start working with extension development using test driven approach, with Magento 2. I do not see any resources and tutorials from where I get idea. I believe I have a fair amount of ...
2
votes
0answers
70 views

Magento2 Unit Testing

I'm trying to understand the Unit Testing for Magento2. public function getPostUrl() { $ticketId = $this->getRequest()->getParam('ticket_id'); $params = ['ticket_id' => $ticketId]; ...
2
votes
0answers
180 views

How to write Unit test for my blocks in magento 2

I have created a module and its working fine. I want to write Unit test for it(i know that i should write unit test before writing code). I tried this way , but i am not clear about it. My Block ...
1
vote
0answers
22 views

Executing Jasmine tests for frontend theme's

I can't get some of the Jasmine tests for the frontend (blank and luma themes) to work. I have generated the static files as described in the documentation. $ bin/magento setup:static-content:deploy ...
1
vote
0answers
128 views

Code Coverage with Jasmine Unittests in Magento2

I am trying to set up the jasmine Unittests for Magento 2. I've already edited the settings.json inside the dev/tests/js/jasmine/spec_runner directory, to only test my own unit tests because I don't ...
1
vote
1answer
147 views

Magento 2 magic methods phpunit tests

I've started learning and at the same time writing tests for my Magento 2 custom development. Not a ride in the park. It feels like digging a pit in the sand sometimes. I got to the point where I need ...
1
vote
0answers
66 views

Magento 2 : How can I test save and delete model?

I have the problem with writing unit tests. It's my first attempt and I don't know how can I test a couple of cases in my code. It's action in my controller: public function execute() { ...
1
vote
1answer
95 views

How to run unit tests without using Selenium?

Is it possible to run MTF without using Selenium? The main aim is to run tests on the web-server (Running Debian), we don't have any web browsers on the web server.
0
votes
0answers
19 views

Issues with MFTF installation Magento 2.3.1

I am facing issues during installation of MFTF unit testing framework. I am following the below link: https://www.vtnetzwelt.com/ecommerce-blog/magento-development-blog/magento-functional-testing-...
0
votes
1answer
89 views

What is the use of Test/Unit folder in module ? What is the purpose?

In magento 2, I see in so many modules that there are Test/Unit folder available. I know little bit about that it used for unit test purpose. But, I want to know that : What is the purpose of this ...
0
votes
1answer
205 views

How to create mock for factory classes?

In unit testing I want to create mock object for factory classes e.g. $this->getMockBuilder(\Magento\Framework\Controller\Result\RawFactory::class)->disableOriginalConstructor()->getMock(); but I ...
0
votes
0answers
372 views

Unit test in magento 2 Error: Call to a member function getAllVisibleItems() on null

Am finding difficult to unit test my custom functions. Below is my custom module's model function which i used for fetching cart informations. <?php namespace Namespace\MiniCart\Model; use ...
0
votes
1answer
29 views

Magento 2 TEST_SUITE=functional ACCEPTANCE_INDEX=1

Pull request errored with message: "The job exceeded the maximum time limit for jobs, and has been terminated." ref: https://travis-ci.org/magento/magento2/jobs/285215690 Never used before.! what ...
0
votes
1answer
83 views

Magento EE 2.1 : error of parameter type in Unit Test

Using this post, I tried my first Unit Test. The goal is to test a repository. However, despite mocking all required dependancies of the repository, I get this error: PHP Fatal error: Uncaught ...
0
votes
1answer
153 views

How can I install and use the Magento Test Framework (without using pear to install phpunit, on Linux Mint 17)

I am trying to set up some sort of automated application testing for Magento stores using the MTAF package described at these links: Guide, Docs These guides tell you to install PHPUnit using pear, ...