You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@netbeans.apache.org by Rahul Khandelwal <ra...@gmail.com> on 2021/05/20 12:14:10 UTC

Help Needed with writing unit tests for diff use case.

Hi All,

I am trying to add "compare with clipboard" functionality in netbeans.
On a high level, this will do the following -
1. either compare clipboard text to opened file
2. or compare clipboard text to selected text in file.

I have got the functionality working in similar way as following tutorial -
http://netbeans.apache.org/wiki/DevFaqEditorHowToAddDiffView.asciidoc

I have now the following questions -
1. Do we already have something similar to *EditableStreamSource*, which we
can reuse?
2. How do I write unit tests for this functionality? At the very least I
need to be able to mock FileObject, Clipboard, EditorRegistry and
DiffController.

Please help me over here.

Thanks and regards,
Rahul Khandelwal

Re: Help Needed with writing unit tests for diff use case.

Posted by Jaroslav Tulach <ja...@gmail.com>.
Dne čtvrtek 20. května 2021 14:14:10 CEST, Rahul Khandelwal napsal(a):
> Hi All,
> 
> I am trying to add "compare with clipboard" functionality in netbeans.
> On a high level, this will do the following -
> 1. either compare clipboard text to opened file
> 2. or compare clipboard text to selected text in file.
> 
> I have got the functionality working in similar way as following tutorial -
> http://netbeans.apache.org/wiki/DevFaqEditorHowToAddDiffView.asciidoc
> 
> I have now the following questions -
> 1. Do we already have something similar to *EditableStreamSource*, which we
> can reuse?
> 2. How do I write unit tests for this functionality? At the very least I
> need to be able to mock FileObject, 

No need to create own mock, use one of existing: Like 
FileUtil.createMemoryFileSystem().

> Clipboard, 

There is 
https://bits.netbeans.org/12.0/javadoc/org-openide-util-ui/org/openide/util/
datatransfer/ExClipboard.html - its subclass NbClipboard is registered via 
@ServiceProvider and that could be mocked by MockServices.

-jt

> EditorRegistry and
> DiffController.
> 
> Please help me over here.
> 
> Thanks and regards,
> Rahul Khandelwal





---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@netbeans.apache.org
For additional commands, e-mail: dev-help@netbeans.apache.org

For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists