Showing posts with label SG. Show all posts
Showing posts with label SG. Show all posts

Thursday, 5 October 2017

Unit Testing using xUnit

Unit Testing is a level of software testing where individual components of a software are tested. The purpose is to validate that each unit of the software perform its required functionality properly.

In Software development Unit Test methods are written to test the code internally while the code gets executed, it makes the development Test driven. Below is the flow diagram that shows how test method works:
The above diagram makes the flow of unit test execution very clear. So now, we’ll discuss our topic Unit testing using xUnit framework.

xUnit framework helps in writing test methods in .net. The xUnit test runner contains the program entry point to run your tests. Dotnet test starts the test runner using the unit test project you've created.
Below is the basic example to write xUnit Unit test for .net Service:

using System;

namespace Number.Services
{
    public class PrimeService
    {
        public bool IsPrime(int number)
        {
            if (candidate == 1)
          {
            return false ;
          }
            throw new NotImplementedException("Please create a test method");
        }
    }
}
 Each Test method should group these functional sections as shown in the test method below:

1 Arrange all necessary preconditions and inputs.
2 Act on the object or method under test.
3 Assert that the expected results have occurred or not.

using Xunit;
using Number.Services;

namespace Number.UnitTests.Services
{
    public class PrimeService_IsPrime
    {
        private readonly PrimeService _primeService;

        public PrimeService_IsPrime()
        {
            _primeService = new PrimeService();
        }

        [Fact]
        public void ReturnFalseForValue1()
        {
            //Arrange
            var number = 1;

            //Act
            var result = _primeService.IsPrime(number);

            //Assert
            Assert.True(result, false );
        }
    }
}
 The above test will pass as the code in the actual method returns false and we are also checking that if the result is false.

The [Fact] attribute indicates a test method that is run by the test runner. Eexecute dotnet test to build the tests and the class library and then run the tests. 

The above example does not contain dependencies but if the code has dependency on other layers of the project the best practice is to MOQ the dependencies and then test the code.
The above diagram shows how the Mocking is different. MOQ is basically a nuget package that you can use to mockup any dependency. MOQ is the only mocking library for .NET developed from scratch to take full advantage of .NET Linq expression trees and lambda expressions, which makes it the most productive mocking library available.It also supports mocking interfaces as well as classes.

You will get an idea of MOQ in below example. Here, I will explain how we write test methods and mock up dependencies.

namespace Products.Controllers
{

public class ProductController : Controller
    {
        private readonly IProductRepository<Product> _productRepository;

        public ProductController(IProductRepository<Product> productRepository)
        {
            _productRepository = productRepository;
        }

        [HttpGet]
        public IActionResult GetAllProduct()
        {
            var data = _productRepository.GetAll().ToList();

            return View(data);
        }
 The above controller method is dependent on repository layer. So to write test method in such scenarios we need to use MOQ framework, as used in the below example:

 using Moq;
using Xunit;

namespace Products.Tests
{
    public class ProductController Tests
    {
        private ProductController _productController;
        private IProductRepository<Product> _productRepository;

        [Fact]
        public void IndexActionReturnsProductList()
        {
            //Arrange
            var products = GetProductList();
            var mock = new Mock<IProductRepository<Product>>();
            mock
                 .Setup(x => x.GetAll())
                 .Returns(products);

            _productController = new ProductController(mock.Object);

            //Act
           
              var data = _productController.Index() as ViewResult;
              var result = (List<Product>) data.Model;

            //Assert
            Assert.Equal(4, result.Count);
        }

        private IQueryable<Product> GetProductList()
        {
            var product= new List<Product>
            {
                new Product
                {
                     Name = "Car",
                     ProductCode= "0986",
                },
                new Product
                {
                     Name = "Scooter",
                     ProductCode= "0945",
                }             
            };
            return product.AsQueryable();
        }
   }
}

In the test method above, we have mocked the ProductRepository and its method GetAll() and instead get data from private method GetProductList() and do the testing and checking the result for controller layer only.

Conclusion: In this way, you can write test methods for all layers of project (i.e. Controller, Services, Repositories, etc.) by mocking the dependencies. Test driven Development helps to make development more bug free and xUnit framework makes it much easier. Hope with this blog you get an overview of writing test methods using xUnit and MOQ.

About Author:
Shivangi Verma  is a consultant in Systems Plus Pvt. Ltd. Within Systems Plus, she actively contributes to the areas of Technology and Information Security. She can be contacted at: Shivangi.Verma@spluspl.com 

Wednesday, 4 October 2017

Persistent Link in SharePoint

As we all know,

SharePoint is very well known for content management and for content sharing.

This time let’s talk about one of the rarely used feature of SharePoint.
“Document ID Service”

Let’s talk about one of the scenario to understand the importance of feature.

Scenario:
We have process set up in HR as new joiner joins company, after induction that person has to fill up one form as employee details and upload it on intranet portal to ‘New Joiner’ document library.

This will trigger one workflow and sends email to HR team with that document link within it.

One day, while HR member accessing documents from ‘New Joiner’ document library accidently one document got misplaced to another folder by him during drag-drop action.
He was not sure where did he dragged that document. At other end, link mentioned in email notification was pointing as ‘Document Does Not exists’!😢

HR team discussed this scenario with us to search that document as that was critical one.

We did manual search within folders and finally found that document, everyone was happy☺

Sometime PAIN become originator of IDEA!☺  

This scenario made us to think on, can we create a link for such documents that will remain same even after document location changes within site?

Persistent Link?☺

Yes we can !

Solution:
There is feature available at site collection level call “Document ID Service”.

This is made up for same purpose that we were looking.

On Activation of this feature it starts to assign Document ids to documents within site collection.

Kindly refer this link to configure this service: Click Here

After configuration it will take some time to assign document id for all documents.

After document ID assignment, document property will look like:
Now, let’s see how we can generate Persistent Link for this document?

There is generic format to construct link , just we need to follow it:


e.g :

And you are all set!☺

This url acts as permanent link for that document.

We can configure our document link within workflow email notification based on this one.

Even though document get rename or its location changes within site collection, document link remains same.

There are some limitations that we need to consider.
Limitation:
1) This is workable only if document move within same site collection.
    Outside site collection move, this link will not work.
2) Under certain circumstances the Document ID is not always maintained. The      following table summarizes these exceptions.

Action
Result
Tried to send a file from one library to another using the ‘Send To’ command (in same SharePoint Site)
Document is considered a copy and a new document ID will be assigned.
Tried to copy a file between two libraries using file explorer view
Document ID not preserved
Tried using the Copy command in “Manage Content and Structure
Document ID not preserved
Cutting & Pasting a file between two SharePoint libraries using file explorer view
Document ID preserved
Tried using the Move command in “Manage Content and Structure”
Document ID preserved

About Author:
Vishal Himane is a consultant in Systems Plus Pvt. Ltd. Within Systems Plus, he actively contributes to the areas of Technology and Information Security. He can be contacted at: vishal.himane@spluspl.com

Friday, 15 September 2017

Blockchain

What is the future of technology? We are hearing buzzwords all around with Vladmir Putin saying “The nation with the best and the most advanced Artificial Intelligence technology, they would be the one who would have control over the world”, but today I will not talk about Artificial Intelligence , as we have heard quite enough about it lately with Elon Musk and Zuckerberg fighting over that whether AI would be a boon or a curse for us . But today I’m going to talk about a technology which is currently making waves and will change how the industry would work in coming years for sure. "Blockchain", the technology behind the cryptography currency Bitcoin. 

Many people know it as the technology behind Bitcoin , the cryptography currency, but Blockchain’s potential uses extend far beyond digital currencies.

Currently, for transfering funds ,what happens is people simply depend on a middleman such as a bank , which ensures the transaction between two party is being done successfully. But what blockchain allows is it enables consumers and suppliers to connect directly and perform transaction, removing the middleman , in this case the bank. 

So the question here is now , what the heck is Blockchain?

Blockchain is fundamentally a ledger, a record keeping book. A ledger meaning it keeps the track of transactions taking place , Now what ledger are , they essentially are private, we don’t tend to share that information of transaction with anyone , but what Blockchain says here is that the ledgers would be public and will be accessible and are going to be shared across all people of interest and that’s the foundational aspect of Blockchain , that in the end it’s basically a record keeping system which keeps a track on any transaction taking place between two parties and also keeping the record public .

The next question that arises in mind would be “What about security”? Is it safe? What if hackers try to hack that particular chain of transaction and retrieve data from it? What then?

The answer to this question is pretty convincing as well as one of the main reasons for the breakthrough of the blockchain , What happens is when a transaction goes through , cryptography secures the data and the new transaction are always linked to the previous one’s in the chain making it almost impossible to alter older records without having to change the subsequent one’s. The linking I’m talking about is done by storing “hash”. Each block is identified by a cryptographic hash of that data. The same hash will always result in that data, but it is impossible to re-create data from hash value . Previous block will have the hash of its previous block embedded in it, and so if a new block is added to the chain , the new block would have a field which will store the hash of its previous block and so on. This is the reason its hard to tamper with. Diagram below is showing how hash are stored.
Also as I said there are multiple computers/nodes which run in this network , In order to gain control of the whole system , one would need to gain access to more than half of the computers in the network, then only it will be possible for him to make changes.

Okay after that you’ll probably think , How will this actually work?

Let me explain to you in a very simple language, with a diagram of course 
Have a look at the diagram, it shows the simple flow of how actually Blockchain works-
  • l It simply requests a transaction, that request is broadcasted to Peer-to-Peer network consisting of other computers known as nodes.
  • l These network of nodes validates the transaction and the user’s status using known algorithm.
  • l A verified transaction can involve cryptocurrency, contracts, records or other structured information.
  • l Once verified, the transaction is combined with other transactions to create a new block of data for the ledger.
  • l The new block is then added to the existing blockchain, in a way that is permanent and unalterable, it cannot be tampered with easily.
  • l The transaction is complete.
The concept of Bitcoin is not just record keeping book for transaction between two parties, now the concept has evolved a lot, it’s being used in quite a different ways.

A company named Bitnation, is using blockchain for a different use altogether other then using it in bitcoin , cryptocurrencies. They started a project aiming to decentralize everything. What they are doing is they are providing a digital ID more of an emergency ID card to the victims of the refugee crisis and bitcoin-based credit card which can be used to receive funds from family member and/or friends without involving any bank accounts. This can also be a way of identifying an individual through family relations cryptographically. 

Also many major companies are also trying a way to simplify and also and trying to better understand supply chain, where blockchain can record every step through which your product goes through before you see them at your local store. You can eventually go back and check that the promises they give of Green tea being 100% organic, the price of the product are actually what they should be. It will give a level of transparency like no other.

Blockchain is also being implemented in Music, Fashion industry as well.

So you can just imagine the countless possible scenarios that Blockchain can be tweaked according to our needs. I’m currently researching more on Blockchain as it is quite vaste, will update this blog as soon as I’ve got something new to share.

About Author:
Pranav Harshe
  is a consultant in Systems Plus Pvt. Ltd. Within Systems Plus, he actively contributes to the areas of Technology and Information Security. He can be contacted at: 
pranav.harshe@spluspl.com

Friday, 28 July 2017

All about Hackathon-MMXVII: Amazon’s Echo Dot

WHAT IS HACKATHON? 
Also known as a code fest or hack day is a sprint like event that lasts between a day and a week, in which all entities involved in software development participate and achieve a solution for given problem. It gives the teams flexibility to use various programming languages as well as hardware devices.

WHY ARE HACKATHONS CONDUCTED?
Hackathons prove a ground for every team member to present new ideas. It stimulates the team members to think and act out of the box. Hackathons provide a platform to integrate and boost up problem solving skills and creativity, which in day to day work routine might get stagnant. Also, it is a great way to rejuvenate innovations.

WHAT WAS SCAN-IT HACKATHON 2017 ABOUT?
Scan-IT Hackathon 2017 was conducted on 25th and 26th of May ,2017 with 12 members representing Systems+. Our objective was to add 1 or more skills to Alexa’s skill-set. These could either focus on Scan-IT’s ERP product: Phoenix, or just be utilitarian in nature. 

WHAT IS ALEXA?
Alexa is the brain behind Amazon’s echo dot, which is capable of recognizing voice commands and processing them for further operations. Alexa is capable of processing everything from simple day to day chores to computing heavy calculations. For example, “Alexa, play music”, “Alexa, add apples to my shopping list “etc.

THE APPROACH TO IMPLEMENT THE SOLUTION:
Once we started exploring about Alexa, the possibilities of developing skills were endless. The traditional way to make a skill set is by use of AWS Lambda Function. AWS lambda function is a service that allows execution of code without any use of servers. We built few skills that could send emails and messages using IFTTT: If This Then That. We also explored various possibilities with the use of Node-RED and Losant. We also wanted to try IBM’s Watson which would be interesting as there would be use of 2 AI’s, but could not due to time constraint.

RESULTS ACHIEVED: 
We built many skills using different API’s but apart from this we tried controlling computer with Alexa which was an achievement for us. We could browse into computer and ask it to pop up with any folder or application we wanted. The control could be as simple as opening a notepad and filling it with content you wish without use of keyboard. We also built an automation to Phoenix application where we could connect to VPN as well as open the application and browse through a filtered set of entries. Other skills included day to day chores of Alexa helping with shopping lists, booking cab, sending out emails, enlightening us with unknown facts and few more. But the possibilities of developing skills were limitless.

CHALLENGES WE FACED:
Amazon’s echo is a machine that is voice interactive with the user. To make smart use of it, it is very essential to make proper use of technologies which fit the puzzle perfectly. While making applications for Alexa the biggest challenge we faced was that it can’t interpret complex word commands. The voice commands given to Alexa should be crisp and clear to make the most efficient processing. The device needs constant power supply and WIFI connection, which can prove a drawback whilst travelling.

CONCLUSION: 
Hackathon made every participant in our team to come up with creative ideas. Two days of hackathon taught us about team spirit, sharing of knowledge and ideas, interaction with team members, implementation of ideas using various technologies but most of all about Alexa. Within two days of hackathon Alexa had become a part of our team. It was not just a device for us anymore, but a team member itself. Alexa introduced us to the world full of creativity and imagination where any thought could be made a reality like a magic. While designing skills for Alexa we realised that there is a lot more to the world of AI than just automation. It challenged us to think more and beyond boundaries. Last but not the least, it was altogether great and magical experience.

About Author:
Ammara Ansari is a consultant in Systems Plus Pvt. Ltd. Within Systems Plus, she actively contributes to the areas of Technology and Information Security. She can be contacted at: ammara.ansari@spluspl.com

Friday, 5 May 2017

Negative Testing in Software testing

Definition: Negative testing is a testing process where validation is done by passing Invalid, Incorrect and False-Positive Input test data & also with scenarios which have a negative impact on business functionality.


The survey shows that count of issue related to negative testing is much more than count of issues of positive testing this shows the importance of negative testing towards user experience. Negative testing ensures application is fault proof.

Some of Negative scenarios

 1>  Negative  scenarios

a.    Null (if mandatory)    : Invalid test data
b.    Less than minimum   : Incorrect length test data
c.    More than maximum  : Incorrect length test data
d.    Other than defined data type : Invalid test data
e.    Duplication check
f.     False Positive test
g.    Less/More than stock/balance quantity
h.    Less/More than available amount
i.      Disaster recovery -  Roll back

Listed Negative testing scenarios also included in Smoke test as passing negative testing scenarios gives extra confidence on Quality of application & delivery.


Negative scenarios are identified as per type of application, User who will be using application, rollback scenarios, 

By knowing type of application & users who will be using it, identification of negative scenarios becomes much more effective for example: if an application would be used by Layman user then all possible negative scenarios should be listed whereas for application which will be used by trained executive would not require all negative scenarios.

Sometimes it become difficult to take decision, should we resolve all reported negative issues in such cases management may sort as per priority (must have), good to have & known issue

The following are some of the benefits of negative testing:
  • It benefits in measuring the functional transparency.
  • It benefits identifying the risk conditions under which the system crashes.
  • It assists in preventing/detecting serious flaws in the exception handling mechanisms.
  • Ensures that the function/application accept the data correctly and handles invalid data in the right way.
Positive testing is done to ensure that the happy business functionality is achieved, negative testing ensures that there is no fault & user experience is good. Negative testing helps to find more defect thus including negative scenarios in test case would have more defect prevention approach.

About Author:
Vinayak Jadhav is a consultant in Systems Plus Pvt. Ltd. Within Systems Plus, he actively contributes to the areas of Technology and Information Security. He can be contacted at:  vinayak.j@spluspl.com

Friday, 21 April 2017

Bridging Miscommunication Gaps Within Team

“We need to talk “

Did you cringe a little ? The above sentence can cause a lot of anxiety, that something is dreadfully wrong.

Poor communication can hinder teamwork such as team communication, presumption and sometimes even lose the trust in a team member. Good communication alongside discipline and responsibility can serve as a very essential part of any project success. Discipline and responsibility can be more of accounted on an individual level, but communication is more of a team effort.
How can you at individual level avoid poor communication? :
Listen: Before presenting your opinion about anything, listen keenly to what is being discussed in the team and what your team members are emphasized. Often it happens that there are various distractions and we forget to pay attention to what is being discussed. The lack of paying attention can miss out a very important point. To avoid loss of data, you can even write down small notes in order to remember most of the discussion

Carousal of meetings: Often it so happens that there are short video conferencing or calls or communications via mail. This detachment is a huge communication barrier. Having stand-up meetings regularly to have a touch base and solicit feedback from team members can really prove effective in good communication within the team. Make sure that you encourage your team to have regularized stand-up meetings and actively participate in them. Informal get togethers within the team, like team lunches, parties, etc., go a long way toward turning colleagues into friends, which inevitable leads to a much deeper level of trust & consequently, better communication

Brainstorming: This can be an effective way to break ice between team members. These sessions can really be helpful to know an individual’s mindset better. It is a creative technique that produces numerous ideas. One can be expressed about self thought process during such sessions.

Speaking the right Language: We all tend to prefer “language” for communication. Some people understand better when provided a statistical data, whereas others may favour graphs and pie charts. Many will prefer story telling and anecdotes. In order to make every team member in sync, it is important to present your view in a “language” that everyone understands.

Respond promptly: The response time that is taken can effectively matter communication. A tardy response can leave the front person with an impression that you are too busy to reply. Procrastination may lead to major communication gaps. Responding back instantly as simple as “ I will get back to you “ can be really effective. Also checking your mails, messages and missed out calls on a regular basis can keep you updated.

Taking ownership: As a part of a team, every member in it should know that what roles they play to achieve goals. For this it becomes vital that you take ownership of a task and manage it throughout the process.

Affable: Personalities of individual team members also impact their communication with their teammates. A cordial & gregarious personality, makes it much more comfortable for teammates to approach you.

Conclusion: 
Last but not least, better communication is a step towards an efficient team. The matter of fact is that we should not restrict communication only in meetings but have a transparency with team members.

About Author:
Ammara Ansari is a consultant in Systems Plus Pvt. Ltd. Within Systems Plus, she actively contributes to the areas of Technology and Information Security. She can be contacted at: ammara.ansari@spluspl.com

Defect Clustering And Pesticide Paradox In Software Testing

When we discuss principle of testing, Defect clustering & Pesticide Paradox are two important principles of testing which often called together.

Defect Clustering
In an application small number of modules contains maximum number of bugs or shows most operational failures
Once defect clustering is identified, testers will focus on these known areas that may also be called as Hotspots, same information is helpful for development team also as they can emphasis more on major affected modules.
Defect clustering cases are often include in Smoke testing which ensures major complex conditions are verified. Defect clustering analysis is often done after first round on test by Project manager or Test manager with the help of defect sheet. Defect sheet should have information of Module for all reported defect. Manager can take pivot of Module Vs Defect count and easily analysis occurrence of Defect clustering

Moreover it is based on the Pareto principle, also known as the 80-20 rule, where 80% of issues are from 20% of modules. 

Importance of Defect Clustering 
  • QC can focus on the same modules/functionality in order to find more number of available bugs
  • Time is saved thus cost for finding defects
Below is the sample example which shows identified modules (highlighted) of Defect clustering.

Module
Count of issues
Percentage %
Master 1
4
2.07253886
Master 2
8
4.14507772
Master 3
28
14.50777202
Master 4
5
2.590673575
Master 5
9
4.663212435
Transac 1
24
12.43523316
Transac 2
25
12.95336788
Transac 3
6
3.10880829
Transac 4
33
17.0984456
Report 1
22
11.39896373
Report 2
8
4.14507772
Report 3
21
10.88082902
Total
193
Pesticide Paradox
Pesticide paradox refers to when same set of test is executed again & again then eventually the same test case would no longer find new bugs.

After 2 or 3 rounds of testing, count of new defects start dropping as most of the bugs got fixed by cleaning ‘Hot Spot’ area. Development team put more focus & become extra careful in those module where testers found more defect and might overlook in other places 

Thus by executing same set of test cases would no longer gives more defect. The test case should be updated for new & different type of test in such a way that it will produce more defects

Methods to Avoid pesticide paradox
  • Preparing new set of test cases & updating it tot already available test case
  • Developing new set of tests case to perform test on different function/module of software 
By using above methods testers can find more effective defects in the modules which are not been focused by testers earlier or modules which are not taken extra care as testers are focusing in defect clustering modules

The first method is time consuming, as number of cases will be too large thus increase the testing time and in turn will increase the cost of testing.

To manage this testers should identify & remove test cases which are of less importance & are of low priority.

Testers can identify & remove useless test cases without compromising with the quality as all the test cases covering important areas of the software will be retained.

Bottom Line:
Defect cluster is useful during initial round of testing but it is always good to use one of the Pesticide Paradox method

Although created test case has maximum coverage and average rate of finding defects is high but we still need to keep updating, reviewing test cases on regularly basis.

About Author:
Vinayak Jadhav is a consultant in Systems Plus Pvt. Ltd. Within Systems Plus, he actively contributes to the areas of Technology and Information Security. He can be contacted at:  vinayak.j@spluspl.com