<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Nipun Arora</title>
    <description>The latest articles on DEV Community by Nipun Arora (@nipunarora).</description>
    <link>https://dev.to/nipunarora</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F240726%2Ff7420d84-1e1d-4995-94f8-2895de073869.jpeg</url>
      <title>DEV Community: Nipun Arora</title>
      <link>https://dev.to/nipunarora</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/nipunarora"/>
    <language>en</language>
    <item>
      <title>Using Mockito for Java Unit Testing</title>
      <dc:creator>Nipun Arora</dc:creator>
      <pubDate>Wed, 02 Oct 2019 18:47:36 +0000</pubDate>
      <link>https://dev.to/nipunarora/using-mockito-for-java-unit-testing-28jp</link>
      <guid>https://dev.to/nipunarora/using-mockito-for-java-unit-testing-28jp</guid>
      <description>&lt;p&gt;&lt;strong&gt;References:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://www.journaldev.com/21816/mockito-tutorial"&gt;Mockito Tutorial JournalDev&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://www.tutorialspoint.com/mockito/index.htm"&gt;Mockito Tutorialspoint&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://javacodehouse.com/blog/mockito-tutorial/"&gt;Mockito Tutorial JavaCodeHouse&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://www.vogella.com/tutorials/DependencyInjection/article.html"&gt;Dependency Injection&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=""&gt;Reflections&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;As I returned back to Java programming, I had to revise my concepts of Junit testing and Mockito. The following is a refresher with quick mockito basics for anyone who wishes to go through them. &lt;/p&gt;

&lt;p&gt;&lt;em&gt;Note: Keep in mind the current version is as and when I am learning mockito myself&lt;/em&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  What is a Mock?
&lt;/h2&gt;

&lt;p&gt;A Mock is a Proxy based instance which routes all calls to a mocking library. When mocking a class the mock creates a instance of the class. Mock allows us to have &lt;em&gt;stubs&lt;/em&gt;, which allow the developer to specify the response for any method invoked on the Mock. The default when the mocked invocation has not been &lt;em&gt;stubbed&lt;/em&gt; is to return &lt;em&gt;null&lt;/em&gt;.&lt;/p&gt;

&lt;p&gt;At a high level we divide mocking in the following broad steps&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://paper.dropbox.com/doc/Mockito-with-Junit-Testing-in-Java--AlzVHWB354hgnUqz_1Ab43yJAg-PXML9ZF7wvcOu2lfIIuAK#:uid=393942277091615114824900&amp;amp;h2=Initialization"&gt;Initiation&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://paper.dropbox.com/doc/Mockito-with-Junit-Testing-in-Java--AlzVHWB354hgnUqz_1Ab43yJAg-PXML9ZF7wvcOu2lfIIuAK#:uid=297402509031141497010540&amp;amp;h2=Stubbing"&gt;Stubbing&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://paper.dropbox.com/doc/Mockito--Al30sCMXsXmeLJNFBGo2AnPTAg-PXML9ZF7wvcOu2lfIIuAK#:uid=701200760644016654936682&amp;amp;h2=Verification"&gt;Verification&lt;/a&gt;
## Initialization
Reference: 

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://stackoverflow.com/questions/15494926/initialising-mock-objects-mockito"&gt;https://stackoverflow.com/questions/15494926/initialising-mock-objects-mockito&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;Option 1:&lt;/em&gt;&lt;/strong&gt;&lt;br&gt;
Basic self-contained test mock initialization&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;//Creating a mock Object of the given class
&amp;lt;ClassName&amp;gt; mockObj = Mockito.mock(&amp;lt;ClassName&amp;gt;.class);
//example
OrderDao mockOrderDao = Mockito.mock(OrderDao.class);
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;&lt;strong&gt;&lt;em&gt;Option 2:&lt;/em&gt;&lt;/strong&gt;&lt;br&gt;
Using &lt;code&gt;@Mock&lt;/code&gt; annotation&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;@Mock
AddService addService;

@BeforeEach
public void setup() {
  //initMocks works with @Mock, @Spy, @Captor, or @InjectMocks annotated objects
  MockitoAnnotations.initMocks(this);
}

@Test
public void testCalc() {
    calcService = new CalcService(addService);
    int num1 = 11; int num2 = 12; int expected = 23;
    when(addService.add(num1, num2)).thenReturn(expected);
    int actual = calcService.calc(num1, num2);
    assertEquals(expected, actual);
}
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;&lt;strong&gt;&lt;em&gt;Option 3:&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;
&lt;h2&gt;
  
  
  Stubbing
&lt;/h2&gt;

&lt;p&gt;Stubbing provides capability to define how method calls behave using a when/then pattern. Calling &lt;code&gt;Mockito.when()&lt;/code&gt;, returns &lt;code&gt;OngoingStub&amp;lt;T&amp;gt;&lt;/code&gt;, specifying how the invocation behaves using the following alternatives:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;&lt;code&gt;thenReturn()&lt;/code&gt;: &lt;/p&gt;

&lt;p&gt;Returns value based on the return type of the operation being stubbed&lt;br&gt;
&lt;/p&gt;

&lt;pre class="highlight plaintext"&gt;&lt;code&gt;List&amp;lt;OrderSummary&amp;gt; orderSummaryFixtureList = //Add fixture data

//the following two lines can ideally be compressed into a single call
OngoingStub&amp;lt;List&amp;lt;OrderSummary&amp;gt;&amp;gt; invocationStub = Mockito.when(mockOrderService.getOrderSummary(customerID)); 
invocationStub.thenReturn(orderSummaryListFixture);

//Simple invocation
Mockito.when(mockOrderService.getOrderSummary(customerID)).thenReturn(orderSummaryListFixture);
&lt;/code&gt;&lt;/pre&gt;




&lt;/li&gt;
&lt;li&gt;

&lt;p&gt;&lt;code&gt;thenThrow()&lt;/code&gt;: &lt;br&gt;
Test exceptions, which the stub throws&lt;br&gt;
&lt;/p&gt;

&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Mockito.when(...).thenThrow(new OrderServiceException("Test Error"));
&lt;/code&gt;&lt;/pre&gt;



&lt;p&gt;&lt;strong&gt;Void Methods&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Mocking void methods do not work with the OngoingStub&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;code&gt;Mockito.doThrow()&lt;/code&gt; returns the Stubber class&lt;br&gt;
&lt;/p&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;//verbose example of using stubber
Stubber stubber = Mockito.doThrow(newOrderServiceException("Test error reason"))
stubber.when(mockOrderService.processOrder(orderFixture));

//compact example of using stubber
Mockito.doThrow(...).when(mockOrderService.processOrder(orderFixture));
&lt;/code&gt;&lt;/pre&gt;

&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;
&lt;li&gt;

&lt;p&gt;&lt;code&gt;thenCallRealMethod()&lt;/code&gt;: &lt;br&gt;
Sometimes it may be useful to delegate the call to a real method in this scenario mockito allows you to call the actual real method instead. The following is an example of how to delegate the call to the real method instead of the stubbed one.&lt;/p&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Mockito.when(mockObject.targetMethod()).thenCallRealMethod();
&lt;/code&gt;&lt;/pre&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;code&gt;thenAnswer()&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Answering allows you to provide a means to conditionally respond based on mock operation parameters&lt;/p&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Mockito.when(mockObject.targetMethod(Mockito.any(String.class))).thenAnswer(new Answer() {
    Object answer(InvocationOnMock invocation){
        ...
    }
});
&lt;/code&gt;&lt;/pre&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;h2&gt;
  
  
  Verification
&lt;/h2&gt;

&lt;p&gt;Mockito framework keeps track of all the method calls and their parameters to the mock object. Mockito &lt;code&gt;verify()&lt;/code&gt; method on the mock object verifies that a method is called with certain parameters. We can also specify the number of invocation logic, such as the exact number of times, at least specified number of times, less than the specified number of times, etc. We can use &lt;code&gt;VerificationModeFactory&lt;/code&gt; for number of invocation times logic. &lt;a href="https://www.journaldev.com/21855/mockito-verify"&gt;Mockito verify&lt;/a&gt;() method checks that a method is called with the right parameters. It does not check the result of a method call like assert method.&lt;/p&gt;

&lt;p&gt;Verifying that the mock objects was called, with the specific expected interaction&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Mockito.verify(mockOrderDao).findOrdersByCustomer(CUSTOMER_ID)
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Verification Mode allows extra verification of the operation&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;&lt;em&gt;times(n)&lt;/em&gt;&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;&lt;em&gt;atLeastOnce()&lt;/em&gt;&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;&lt;em&gt;atLeans(n)&lt;/em&gt;&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;&lt;em&gt;atMost(n)&lt;/em&gt;&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;&lt;em&gt;never()&lt;/em&gt;&lt;/strong&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Verifying no interactions globally&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;&lt;em&gt;Mockito.verify().zeroInteractions()&lt;/em&gt;&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;&lt;em&gt;Mockito.verify().noMoreInteractions()&lt;/em&gt;&lt;/strong&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Example:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Mockito.verify(mockOrderService, VerificationSettings.times(2)).method
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;h1&gt;
  
  
  Advanced Mockito Concepts
&lt;/h1&gt;
&lt;h2&gt;
  
  
  Argument Matchers
&lt;/h2&gt;

&lt;p&gt;When you want to stub a function with a specific type of argument you can use argument matchers to generalize return values, for instance&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Mockito.when(mockOrderDao.findByCustomerId(Matchers.anyString())).thenReturn(orderEntityListFixture);
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;If any argument is explicit, all of them must be explicit, in the example below both matchers are either explicit or generic.&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Mockito.when(mockOrderDao.findByStateAndRegion(Matchers.eq("IL"), Matchers.anyString())).thenReturn(orderEntityListFixture);
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;h2&gt;
  
  
  Matchers
&lt;/h2&gt;
&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Matchers.eq(..)
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;The following is a list of matchers for type of object (i.e. match by class). &lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Matchers.anyInt(..) //any integer
Matchers.anyDouble(...) //any double
(String)Matchers.any() // typecasted any to string
Matchers.any(&amp;lt;T class&amp;gt;) //typecasted any Template class
(Set&amp;lt;String&amp;gt;)Matchers.anySet() // ??
Matchers.anySetOf(String.class) // ??
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;ul&gt;
&lt;li&gt;String Matchers&lt;/li&gt;
&lt;li&gt;Reference Equality and Reflection&lt;/li&gt;
&lt;/ul&gt;
&lt;h2&gt;
  
  
  Stubbing Consecutive Calls
&lt;/h2&gt;

&lt;p&gt;Handy for testing logic that needs to be resilient when error occurs:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Looping logic that either short-circuts or continues on exception&lt;/li&gt;
&lt;li&gt;Retry logic when errors are encountered&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Stub multiple responses in order one after the other for giving consecutive returns.&lt;/p&gt;

&lt;p&gt;The following is an example of first throwing an exception and then returning a value. This is an example of successful execution after retries.&lt;br&gt;
&lt;code&gt;Mockito.when(...).thenThrow(...).thenReturn(...)&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;The following is an example where there are multiple failures, so we test throwing multiple exceptions in multiple calls.&lt;br&gt;
&lt;code&gt;Mockito.when(...).thenThrow(...).thenThrow(...)&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Inorder verification&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;inOrderVerifier = Mockito.inOrder(MockOfferService, MockTaxService);
//Verify that the following two are called, and are called in the correct order
inOrderVerifier.verify(MockOfferService)....
inOrderVerify.verify(MockTaxService)...
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;h2&gt;
  
  
  Argument Campturing
&lt;/h2&gt;

&lt;p&gt;Retrieve the object passed to a mock from within the testing code to verify that the correct arguments were passed&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;ArgumentCaptor&amp;lt;Obj&amp;gt; orderEntityCaptor = ArgumentCaptor.forClass(&amp;lt;ClassName&amp;gt;.class);

//Now to actually capture the variables
Mockito.verify(...).function(orderEntityCaptor.capture());

//Get the Captured Value
Object obj = orderEntityCaptor.getValue();
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;h2&gt;
  
  
  Spies
&lt;/h2&gt;

&lt;p&gt;Compared to mocking, a spy wraps an actual instance of the class within a proxy implementation. The default behavior of the spy is to call the real method when no stubbing has been specified. &lt;/p&gt;

&lt;h3&gt;
  
  
  Partial Mocking (TBD)
&lt;/h3&gt;

&lt;p&gt;When partial mocking keep the following things in mind:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Can't mock private methods&lt;/li&gt;
&lt;li&gt;Can't mock final mehtods&lt;/li&gt;
&lt;li&gt;Set the state appropriately&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;When stubbing a spy, the initial call is routed to the real method, this can result in unexpected exceptions&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;List&amp;lt;String&amp;gt; liveList = new LinkedList&amp;lt;String&amp;gt;();
List&amp;lt;String&amp;gt; spyList = Mockito.spy(liveList);

//This will give an exception as it will trigger an empty list because spy first routes call to real method
Mockito.when(spyList.get(0)).thenReturn("A string result");

// The following is a work around
spyList.add("dummy value");
Mockito.when(spyList.get(0)).thenReturn("A string result");
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;






&lt;h1&gt;
  
  
  PowerMock
&lt;/h1&gt;

&lt;p&gt;Mockito does not have &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Ability to mock static operations&lt;/li&gt;
&lt;li&gt;Ability to mock final/private&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;PowerMock provides an extension to Mockito. Uses a custom classloader, and byte code manipulation. &lt;/p&gt;

&lt;h3&gt;
  
  
  Mocking static functions using PowerMock
&lt;/h3&gt;



&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;//Initialize using the following to annotate the test class
@RunWith(PowerMockRunner.class)
@PrepareForTest(value={&amp;lt;ClassName&amp;gt;.class})
public class AbcTest{

}
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;





&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;//stubbing static method using powermock
PowerMockito.mockStatic(&amp;lt;ClassName&amp;gt;.class)
PowerMockito.when(Class.method(Matchers...)).thenReturn(...);

//verifying static method using powermock
PowerMockito.verifyStatic();
Obj argument = ArgumentCaptor.forClass(...).getValue;
// follow up with assertions to verify...
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;h2&gt;
  
  
  Replace Object Instantiation
&lt;/h2&gt;

&lt;p&gt;Calls to "new" operator can be replaced by stubbed results.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;// Call zero parameter constructor by class name
// Use reflection or specific constructor
// Specify specific constructor using a string value
PowerMockito.whenNew(...)
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;whenNew() returns PowerMock's version of &lt;code&gt;OngoingStub&amp;lt;T&amp;gt;&lt;/code&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;code&gt;ConstructorExpectationSetup&amp;lt;T&amp;gt;&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;WithOrWithoutExpectedArguments&amp;lt;T&amp;gt;&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Note: You need to specify the class under test and not the class being instantiated&lt;/strong&gt;&lt;br&gt;
&lt;code&gt;@PrepareForTest(ClassUnderTest.class)&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;OrderCompletionAudit auditFixture = new OrderCompletionAudit();
PowerMockito.whenNew(OrderCompletionAudit.class).withNoArguments().thenReturn(auditFixture);
Assert.assertEquals(ORDER_NO, auditFixture.getOrderNumber());
Assert.assertNotNull(auditFixture.getCompletionDate());
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;h2&gt;
  
  
  Stubbing Final &amp;amp; Private Methods
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Stubbing final operations are straightforward and nothing else expected&lt;/li&gt;
&lt;li&gt;Stubbing private methods requires - pass the mock and a java reflection method object into when method &amp;amp; WithOrWithoutExpectedArguments are returned
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;PowerMockito.verifyPrivate(...) -&amp;gt; returns PrivateMethodVerification, which allows you to verify the private calls

PrivateMethodVerification.invoke(...)

PrivateMethodVerification pmVerification = Mockito.verifyPrivate(mockOrderService);
//Use either this
pmVerification.invoke(method).withArguments(item1, order);

//Or this
pmVerification.invoke("calculateDiscount", item1, order);
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;h2&gt;
  
  
  Whitebox Test Utility Class (TBD)
&lt;/h2&gt;

&lt;p&gt;Wrapper around java reflection api, but geared towards testing&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;good for testing private methods&lt;/li&gt;
&lt;li&gt;removes exception handling- the test will fail if encountered during whitebox method calls&lt;/li&gt;
&lt;/ul&gt;




&lt;h1&gt;
  
  
  Fixture Management
&lt;/h1&gt;

&lt;ul&gt;
&lt;li&gt;Fixture state initialization is performed for each test

&lt;ul&gt;
&lt;li&gt;Instantiate objects to pass into methods&lt;/li&gt;
&lt;li&gt;Declare mock stubs/initialize objects they return&lt;/li&gt;
&lt;li&gt;Insert data in rdbms for data access tests&lt;/li&gt;
&lt;li&gt;Create files&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;TearDown&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Clean up files created, data added to persistent storage&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Managing Object Fixtures
&lt;/h2&gt;

&lt;p&gt;Only do minimum amount of object fixtures.&lt;/p&gt;

</description>
      <category>testing</category>
      <category>junit</category>
      <category>java</category>
      <category>mockito</category>
    </item>
    <item>
      <title>Jekyll Cheatsheet</title>
      <dc:creator>Nipun Arora</dc:creator>
      <pubDate>Wed, 02 Oct 2019 02:59:22 +0000</pubDate>
      <link>https://dev.to/nipunarora/jekyll-cheatsheet-2jke</link>
      <guid>https://dev.to/nipunarora/jekyll-cheatsheet-2jke</guid>
      <description>&lt;p&gt;tl;dr - Started trying out jekyll after I found an excellent blog theme. fwiw I still prefer hugo, but it seems like Jekyll has better themes.&lt;/p&gt;

&lt;h3&gt;
  
  
  Install Jekyll in Mac
&lt;/h3&gt;

&lt;p&gt;&lt;code&gt;brew install ruby&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;After cloning your jekyll website repo, run the following from within the repository to install all required packages&lt;br&gt;
&lt;code&gt;bundle install&lt;/code&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Running Jekyll
&lt;/h3&gt;

&lt;p&gt;To run it in dev mode&lt;/p&gt;

&lt;p&gt;&lt;code&gt;bundle exec jekyll serve&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;To run as prod&lt;/p&gt;

&lt;p&gt;&lt;code&gt;export JEKYLL_ENV=production&lt;/code&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  How to add support for Third parties:
&lt;/h3&gt;

&lt;p&gt;&lt;a href="https://learn.cloudcannon.com/jekyll-third-parties/"&gt;https://learn.cloudcannon.com/jekyll-third-parties/&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Deploy Jekyll blog on netlify
&lt;/h3&gt;

&lt;p&gt;&lt;a href="https://www.netlify.com/blog/2015/10/28/a-step-by-step-guide-jekyll-3.0-on-netlify/"&gt;https://www.netlify.com/blog/2015/10/28/a-step-by-step-guide-jekyll-3.0-on-netlify/&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Publish Jekyll to &lt;code&gt;dev.to&lt;/code&gt;
&lt;/h3&gt;

&lt;p&gt;&lt;a href="https://kodaman2.github.io/blog/How-to-Setup-a-Jekyll-Blog/"&gt;https://kodaman2.github.io/blog/How-to-Setup-a-Jekyll-Blog/&lt;/a&gt;&lt;/p&gt;

</description>
      <category>cheatsheet</category>
      <category>jekyll</category>
    </item>
  </channel>
</rss>
