Questions tagged [controller-tests]
13 questions
7
votes
2 answers
@SpringBootTest: @MockBean not injected when multiple test classes
I want to write controller tests that also test my annotations. What I've read so far is that RestAssured one of the ways to go.
It works smoothly when I only have one controller test in place. However, when having 2 or more controller test classes…

Kyroy
- 173
- 1
- 8
2
votes
3 answers
No qualifying bean of type 'org.springframework.boot.actuate.health.HealthEndpoint' in controller test
I wrote a controller which combines actuator info.
@RestController
@Slf4j
public class AppStatusRestController {
private final HealthEndpoint healthEndpoint;
private final InfoEndpoint infoEndpoint;
public…

makozaki
- 3,772
- 4
- 23
- 47
2
votes
1 answer
Moq; Unit Test - Method is always failing. ISetup is not working
The test method is always failing. After the Setup the method UpdateAsync should return 1 in the result but it remains always 0 which results in exception in the controller method.
Can you tell what I am missing here ?
[Test]
public async Task…

Abhishek Vyas
- 599
- 1
- 9
- 24
1
vote
0 answers
mockMvc.perform is ignoring @pattern annotation on header field when testing controller method
I am using jUnit 5 and Mockito to test my POST API. Here is what my method definition looks like.
public ResponseEntity

Ananya Chaurasia
- 87
- 10
1
vote
1 answer
How to manipulate the application configs for controller tests?
I'm writing functional / controller tests for a ZF3 application (driven by PHPUnit and zendframework/zend-test). Like this:
public function testWhatEver()
{
$this->dispatch('/');
…

automatix
- 14,018
- 26
- 105
- 230
0
votes
1 answer
Getting no route matches when simulating a session in rails minitest
No route matches {:action=>"/login", :controller=>"categories", :email=>"fardeenmhs@hotmail.com", :password=>"fardeen"}
This is happening.
require 'test_helper'
class CategoriesControllerTest < ActionController::TestCase
setup do
@category =…

Fardeen
- 21
- 2
0
votes
0 answers
Java Spring Boot Controller tests fail when mapping with model mapper: org.modelmapper.MappingException: ModelMapper mapping errors
My problem is that I have problems with the model mapper. Here is the configuration for the model mapper:
@Configuration
public class ModelMapperConfig {
@Bean
@Primary
public ModelMapper modelMapper() {
ModelMapper modelMapper…

FireAndBlood
- 21
- 3
0
votes
0 answers
H2 database doesn't autoincrement IDs after them being set to null, while PostgreSQL does
My project uses PostgreSQL for production and H2 database for tests. Some content is saved to database and afterwards it is retrieved, changed and saved again to new rows. In this method some of retrieved contents' IDs are set to null, and…

bluebird
- 1
- 1
0
votes
0 answers
StatementInvalid: SQLite3::BusyException: database is locked
I have referred various answers on StackOverflow but I still haven't been able to resolve this issue. I am sharing the code for my controllers_test.rb and along with that the screenshot. Every time I run rails test, the following error is shown. I…

Rishabh Malhotra
- 25
- 7
0
votes
0 answers
how moq one of the interfaces in controller test
I have a controller class with 2 service interfaces: one is a post method of external URL and the second is a local repository. In the controller test class, I just want to moq the interface1, not the second. How can I do this? Or what is the best…

N.Abdolalizadeh
- 73
- 11
0
votes
1 answer
wrong number of arguments error while testing comments controller using Rspec
While Testing Comments Controller, I get this error while creating a comment.
Failures:
1) CommentsController Valid POST create creates a new comment
Failure/Error: post :create, params: { comment: { content: 'TestCommentContent' },…

David Çonquerør
- 15
- 5
0
votes
0 answers
Rspec rails-controller-testing gem's assigns doesn't work
I'm using Rails 5.2 with rspec-rails 3.7 and rails-controller-testing gems.
I have a controller that filters results on the index action (yeah, bad practice, legacy code, etc). The problem is I need to test that when I do GET work_orders/index…

sbstnssndn
- 145
- 1
- 18
0
votes
1 answer
UrlGenerationError when testing controller usinf Rspec
I am trying to run basic controller test.
My controller_spec.rb looks like:
class Test < ActionController::Base
def test_meth
puts 'hello for test meth'
head 200
end
end
describe Test do
it 'responds with 200' do
get :test_meth
…

Jaleel Ahmed
- 65
- 8