You need both.
In your example if you were testing that a database in a certain condition, when the findByKeyword
method is run you get the data back you expect this is a fine integration test.
In any other code that is using that findByKeyword
method you want to control what is being fed in to the test, so you can return nulls or the right words for your test or whatever then you mock the database dependency so you know exactly what your test will receive (and you lose the overhead of connecting to a database and ensuring the data within is correct)