Questions tagged [unit-testing]

Only for questions that are specific to unit testing Sitecore-based features, controls, renderings and other Sitecore-specific application logic

7 questions with no upvoted or accepted answers
Filter by
Sorted by
Tagged with
2 votes
0 answers
315 views

Mock useSitecoreContext in Nextjs unit tests

I'm trying to write simple unit tests with Jest and mock useSitecoreContext. When I'm mocking the useSitecoreContext like this: useSitecoreContext: jest.fn() I'm getting an error "Cannot ...
Max's user avatar
  • 21
1 vote
0 answers
68 views

Using JustMock With Sitecore 8.2.4 Kernel DLL

I have the following JustMock call in my old 8.0.7 Sitecore project: var siteGuid = Guid.NewGuid(); var siteItem = Mock.Create<Item>(); var id = new ID(siteGuid); Mock.Arrange(() => siteItem....
c-bro's user avatar
  • 567
1 vote
0 answers
329 views

Analytics Tracking Unit Test

I need to create a unit test that will use the following pipeline Sitecore.Analytics.Pipelines.StartTracking It then needs to see if the tracking is enabled and then check if a cookie exists. I saw ...
doctorwho's user avatar
1 vote
0 answers
781 views

Unit testing contentsearch with facets

I am trying to write a test for this code: var publicationYears = new List<string>(); using (var context = searchContextBuilder.GetSearchContext(Indexes.NewsIndex)) { var query = context....
Gatogordo's user avatar
  • 20.1k
0 votes
0 answers
184 views

How to unit test a custom field validator

I have implemented my own field validator that ensures a thumbnail image is always set on a rendering item. Working example: [Serializable] public class MandatoryThumbnailFieldValidator : ...
David Buckell's user avatar
0 votes
0 answers
63 views

Unit Test Fails at AuthenticationManager.Login(virtualUser)

We have a unit test for our Login method using Sitecore 8.2. It fails at the below piece of code and attached the error screenshot follows. Can anybody please let me know how to resolve this error? ...
NewbieHere's user avatar
0 votes
1 answer
436 views

Unit Test fails to run on solution based on Helix Visual Studio Templates

my project solution is based on Sitecore Helix Visual Studio Templates by Ander's Laub. Im trying to write Unit tests using XUnit, but none of the tests are running and not even failing. For test ...
Suman Baul's user avatar